Skip to content

Commit

Permalink
Merge pull request #601 from Azquelt/schema-annotation-updates
Browse files Browse the repository at this point in the history
Schema annotation updates
  • Loading branch information
Azquelt authored May 8, 2024
2 parents 972a655 + cd35c07 commit dfedd16
Show file tree
Hide file tree
Showing 9 changed files with 684 additions and 67 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (c) 2024 Contributors to the Eclipse Foundation
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.eclipse.microprofile.openapi.annotations.media;

/**
* A property name and an associated list of other property names.
* <p>
* Used with {@link Schema#dependentRequired()}, if an object has a property named {@link #name()}, it must also have
* properties with the names in {@link #requires()}.
*
* @see Schema#dependentRequired()
*/
public @interface DependentRequired {

/**
* The property name to look for
*
* @return a property name
*/
String name();

/**
* The property names that an object is required to have, if it has a property named {@link #name()}
*
* @return the required property names
*/
String[] requires();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (c) 2024 Contributors to the Eclipse Foundation
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.eclipse.microprofile.openapi.annotations.media;

/**
* A property name and an associated schema.
* <p>
* Used with {@link Schema#dependentSchemas()}, if an instance has a property named {@link #name()}, then it must
* validate against {@link #schema()}.
*
* @see Schema#dependentSchemas()
*/
public @interface DependentSchema {

/**
* A property name
*
* @return property name
*/
String name();

/**
* The schema that an instance must validate against if it has a property named {@link #name()}.
*
* @return a class used to generate a schema which is used to validate objects with properties named {@link #name()}
*/
Class<?> schema();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright (c) 2024 Contributors to the Eclipse Foundation
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.eclipse.microprofile.openapi.annotations.media;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* A regular expression and an associated schema.
* <p>
* Used with {@link Schema#patternProperties()}, properties with names that match {@link #regex()} must have values
* which validate against {@link #schema()}.
*
* @see Schema#patternProperties()
*/
@Target({})
@Retention(RetentionPolicy.RUNTIME)
public @interface PatternProperty {

/**
* A regular expression to match against property names.
*
* @return an ECMA-262 regular expression
*/
String regex();

/**
* A schema that a property value must validate against
*
* @return a class used to generate a schema used to validate properties with names that match {@link #regex()}
*/
Class<?> schema();
}
Loading

0 comments on commit dfedd16

Please sign in to comment.