Skip to content

Commit dfedd16

Browse files
authored
Merge pull request #601 from Azquelt/schema-annotation-updates
Schema annotation updates
2 parents 972a655 + cd35c07 commit dfedd16

File tree

9 files changed

+684
-67
lines changed

9 files changed

+684
-67
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright (c) 2024 Contributors to the Eclipse Foundation
3+
* <p>
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* <p>
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* <p>
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.eclipse.microprofile.openapi.annotations.media;
17+
18+
/**
19+
* A property name and an associated list of other property names.
20+
* <p>
21+
* Used with {@link Schema#dependentRequired()}, if an object has a property named {@link #name()}, it must also have
22+
* properties with the names in {@link #requires()}.
23+
*
24+
* @see Schema#dependentRequired()
25+
*/
26+
public @interface DependentRequired {
27+
28+
/**
29+
* The property name to look for
30+
*
31+
* @return a property name
32+
*/
33+
String name();
34+
35+
/**
36+
* The property names that an object is required to have, if it has a property named {@link #name()}
37+
*
38+
* @return the required property names
39+
*/
40+
String[] requires();
41+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright (c) 2024 Contributors to the Eclipse Foundation
3+
* <p>
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* <p>
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* <p>
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.eclipse.microprofile.openapi.annotations.media;
17+
18+
/**
19+
* A property name and an associated schema.
20+
* <p>
21+
* Used with {@link Schema#dependentSchemas()}, if an instance has a property named {@link #name()}, then it must
22+
* validate against {@link #schema()}.
23+
*
24+
* @see Schema#dependentSchemas()
25+
*/
26+
public @interface DependentSchema {
27+
28+
/**
29+
* A property name
30+
*
31+
* @return property name
32+
*/
33+
String name();
34+
35+
/**
36+
* The schema that an instance must validate against if it has a property named {@link #name()}.
37+
*
38+
* @return a class used to generate a schema which is used to validate objects with properties named {@link #name()}
39+
*/
40+
Class<?> schema();
41+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright (c) 2024 Contributors to the Eclipse Foundation
3+
* <p>
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* <p>
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* <p>
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.eclipse.microprofile.openapi.annotations.media;
17+
18+
import java.lang.annotation.Retention;
19+
import java.lang.annotation.RetentionPolicy;
20+
import java.lang.annotation.Target;
21+
22+
/**
23+
* A regular expression and an associated schema.
24+
* <p>
25+
* Used with {@link Schema#patternProperties()}, properties with names that match {@link #regex()} must have values
26+
* which validate against {@link #schema()}.
27+
*
28+
* @see Schema#patternProperties()
29+
*/
30+
@Target({})
31+
@Retention(RetentionPolicy.RUNTIME)
32+
public @interface PatternProperty {
33+
34+
/**
35+
* A regular expression to match against property names.
36+
*
37+
* @return an ECMA-262 regular expression
38+
*/
39+
String regex();
40+
41+
/**
42+
* A schema that a property value must validate against
43+
*
44+
* @return a class used to generate a schema used to validate properties with names that match {@link #regex()}
45+
*/
46+
Class<?> schema();
47+
}

0 commit comments

Comments
 (0)