Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schema annotation updates #601

Merged
merged 3 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading