001/* 002 * The contents of this file are subject to the terms of the Common Development and 003 * Distribution License (the License). You may not use this file except in compliance with the 004 * License. 005 * 006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the 007 * specific language governing permission and limitations under the License. 008 * 009 * When distributing Covered Software, include this CDDL Header Notice in each file and include 010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL 011 * Header, with the fields enclosed by brackets [] replaced by your own identifying 012 * information: "Portions copyright [year] [name of copyright owner]". 013 * 014 * Copyright 2016 ForgeRock AS. 015 */ 016 017package org.forgerock.api.annotations; 018 019import java.lang.annotation.ElementType; 020import java.lang.annotation.Retention; 021import java.lang.annotation.RetentionPolicy; 022import java.lang.annotation.Target; 023 024/** 025 * Specify a schema for the element that is being described. 026 * <p> 027 * This annotation can also be used to specify an {@code id} for a schema defined by a type. 028 */ 029@Retention(RetentionPolicy.RUNTIME) 030@Target({ElementType.METHOD, ElementType.TYPE}) 031public @interface Schema { 032 033 /** 034 * The schema identifier. If provided, this schema will be added to definitions and referenced from 035 * anywhere it is used. If null/empty, the schema will be used inline. 036 */ 037 String id() default ""; 038 /** The type to produce the schema from. */ 039 Class<?> fromType() default Void.class; 040 /** 041 * A classpath resource that contains a JSON Schema structure to be used. The path is relative to the type 042 * that the annotated resource method is part of, and will be resolved using the 043 * {@link Class#getResourceAsStream(String)} method on that class instance. 044 */ 045 String schemaResource() default ""; 046 047}