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

OAS 3.1 - annotations and resolve logic #4425

Merged
merged 33 commits into from
Jun 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
b2618d6
OAS 3.1 - updated annotations to support OAS 3.1
HugoMario May 17, 2022
8e9758e
OAS 3.1 - updated util class
HugoMario May 17, 2022
4b8f983
OAS 3.1 - implement OAS 3.1 annotation - prototype
frantuma May 18, 2022
2315ded
OAS 3.1 - added @since annotations to new OAS 3.1 fields
HugoMario May 20, 2022
5210787
OAS 3.1 - added link on annotation to oas 3.1 documentation page
HugoMario May 21, 2022
379d1ef
OAS 3.1 - updated annotations, utils class and added webhook annotation
HugoMario Jun 1, 2022
b2d3a8d
OAS 3.1 - fixed NPE in tests
HugoMario Jun 11, 2022
ca13921
OAS 3.1 - updated schema check method, and fixed errors found on docu…
HugoMario Aug 11, 2022
f08f865
OAS 3.1 - implement initial OAS 3.1 annotations and resolve logic
frantuma Oct 10, 2022
290a874
OAS 3.1 - added OAS 3.1 fields on annotation util methods
HugoMario Oct 31, 2022
3994622
OAS 3.1 - added missed oas3.1 keyword const for schema annotation
HugoMario Dec 24, 2022
0f27720
OAS 3.1 - added oas3.1 option for modelconverter interface
HugoMario Dec 24, 2022
c03294e
OAS 3.1 - updated model resolver class to work with oas 3.1 fields
HugoMario Dec 25, 2022
7bcadce
OAS 3.1 - fixed types for contains and unevaluated items fields
HugoMario Dec 27, 2022
01a6f49
OAS 3.1 - handle dependent schema annotations in resolver class
HugoMario Dec 27, 2022
cfdffd1
OAS 3.1 - added tests for OAS 3.1 model resolver
HugoMario Dec 27, 2022
522aa88
OAS 3.1 - fixed schema maximum value default value comparison.
HugoMario Jan 19, 2023
3a160b6
OAS 3.1 - allow set schema annotation types to schema object types
HugoMario Jan 19, 2023
2105b89
OAS 3.1 - small tweak
HugoMario Jan 19, 2023
a5839ec
OAS 3.1 - use the right mapper for OAS31 serialization
HugoMario Jan 19, 2023
1d305e4
OAS 3.1 - set default openapi version for 3.1.0
HugoMario Jan 19, 2023
4cdbaba
OAS 3.1 - use right mapper for serialization
HugoMario Jan 19, 2023
55a4cff
OAS 3.1 - updated Reader class to work with openapi31, added tests to…
HugoMario Jan 22, 2023
915b817
OAS 3.1 - overload annotation utils methods to work with openapi 3.1
HugoMario Jan 22, 2023
bb8a772
OAS 3.1 - updated parameter processor class to work with openapi 3.1
HugoMario Jan 22, 2023
9c69c3b
OAS 3.1 - added tests to verify parameters read process
HugoMario Jan 23, 2023
7b79fc1
OAS 3.1 - added test for callback
HugoMario Jan 23, 2023
ba0c6a6
OAS 3.1 - added tests for request body
HugoMario Jan 23, 2023
464567b
OAS 3.1 - added support for webhooks.
HugoMario Jan 25, 2023
b959817
OAS 3.1 - check _const value in schema annotation validation
HugoMario Jan 25, 2023
90dd730
OAS 3.1 - use right method to resolve schema
HugoMario Jan 25, 2023
af72bb6
OAS 3.1 - updated test
HugoMario Jan 25, 2023
7174a10
OAS 3.1 - minor tweaks and tests
frantuma Jun 12, 2023
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,14 @@
package io.swagger.v3.oas.annotations;

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

import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.ElementType.METHOD;

@Target({METHOD, ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface OpenAPI31 {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package io.swagger.v3.oas.annotations;

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

import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.ElementType.METHOD;

@Target({METHOD, ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface StringToClassMapItem {
String key();
Class<?> value();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package io.swagger.v3.oas.annotations;

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

import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.ElementType.METHOD;

/**
* The annotation may be used to define a method as an OpenAPI Webhook.
*
* @see <a target="_new" href="https://github.com/OAI/OpenAPI-Specification/blob/3.1.0/versions/3.1.0.md#oasWebhooks">Webhook (OpenAPI specification)</a>
* @see io.swagger.v3.oas.annotations.OpenAPIDefinition
**/
@Target({METHOD, ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Inherited
@OpenAPI31
public @interface Webhook {
/**
* Provides the name related to this webhook.
* @return webhook name
*/
String name();

/**
* Provides the operation related to this webhook.
* @return webhook operation
*/
Operation operation();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package io.swagger.v3.oas.annotations;

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

import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;

/**
* Container for repeatable {@link Webhook} annotation
*
* @see Webhook
*/
@Target({TYPE, ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Inherited
@OpenAPI31
public @interface Webhooks {

/**
* An array of Webhook annotations
*
* @return the array of the Webhook
**/
Webhook[] value() default {};
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.swagger.v3.oas.annotations.info;

import io.swagger.v3.oas.annotations.OpenAPI31;
import io.swagger.v3.oas.annotations.extensions.Extension;

import java.lang.annotation.ElementType;
Expand All @@ -12,6 +13,7 @@
* The annotation may be used in {@link io.swagger.v3.oas.annotations.OpenAPIDefinition#info()} to populate the Info section of the OpenAPI document.
*
* @see <a target="_new" href="https://github.com/OAI/OpenAPI-Specification/blob/3.0.1/versions/3.0.1.md#infoObject">Info (OpenAPI specification)</a>
* @see <a target="_new" href="https://github.com/OAI/OpenAPI-Specification/blob/3.1.0/versions/3.1.0.md#infoObject">Info (OpenAPI specification)</a>
* @see io.swagger.v3.oas.annotations.OpenAPIDefinition
**/
@Target({ElementType.ANNOTATION_TYPE})
Expand Down Expand Up @@ -67,4 +69,13 @@
*/
Extension[] extensions() default {};

/**
* A short API summary.
*
* @since 2.2.12 / OpenAPI 3.1
* @return API summary
**/
@OpenAPI31
String summary() default "";

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.swagger.v3.oas.annotations.info;

import io.swagger.v3.oas.annotations.OpenAPI31;
import io.swagger.v3.oas.annotations.extensions.Extension;

import java.lang.annotation.Retention;
Expand All @@ -9,7 +10,8 @@
/**
* The annotation may be used in {@link Info#license()} to define a license for the OpenAPI spec.
*
* @see <a target="_new" href="https://github.com/OAI/OpenAPI-Specification/blob/3.0.1/versions/3.0.1.md#licenseObject">License (OpenAPI specification)</a>
* @see <a target="_new" href="https://github.com/OAI/OpenAPI-Specification/blob/3.0.1/versions/3.0.1.md#licenseObject">License (OpenAPI 3.0 pecification)</a>
* @see <a target="_new" href="https://github.com/OAI/OpenAPI-Specification/blob/3.1.0/versions/3.1.0.md#licenseObject">License (OpenAPI 3.1 specification)</a>
* @see io.swagger.v3.oas.annotations.OpenAPIDefinition
* @see Info
**/
Expand All @@ -26,7 +28,7 @@
/**
* A URL to the license used for the API. MUST be in the format of a URL.
*
* @return the URL of the license
* @return URL to the license
**/
String url() default "";

Expand All @@ -37,4 +39,13 @@
*/
Extension[] extensions() default {};

/**
* An identifier for a License instance.
*
* @since 2.2.12 / OpenAPI 3.1
* @return the identifier of the license
**/
@OpenAPI31
String identifier() default "";

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.swagger.v3.oas.annotations.media;

import io.swagger.v3.oas.annotations.OpenAPI31;
import io.swagger.v3.oas.annotations.extensions.Extension;

import java.lang.annotation.Inherited;
Expand All @@ -25,13 +26,24 @@
* coexist</p>
*
* @see <a target="_new" href="https://github.com/OAI/OpenAPI-Specification/blob/3.0.1/versions/3.0.1.md#schemaObject">Schema (OpenAPI specification)</a>
* @see <a target="_new" href="https://github.com/OAI/OpenAPI-Specification/blob/3.1.0/versions/3.1.0.md#schemaObject">Schema (OpenAPI specification)</a>
* @see Schema
**/
@Target({FIELD, METHOD, PARAMETER, TYPE, ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface ArraySchema {

/**
* The schemas of the items in the array
*
* @since 2.2.12
*
* @return items
*/

Schema items() default @Schema;

/**
* The schema of the items in the array
*
Expand Down Expand Up @@ -76,4 +88,49 @@
* @return an optional array of extensions
*/
Extension[] extensions() default {};
}

/**
* Specifies contains constrictions expressions.
*
* @since 2.2.12 / OpenAPI 3.1
* @return contains expression.
*/
@OpenAPI31
Schema contains() default @Schema;

/**
* Provides max contains related to this schema
*
* @since 2.2.12 / OpenAPI 3.1
* @return max contains
*/
@OpenAPI31
int maxContains() default 0;

/**
* Provides min contains related to this schema
*
* @since 2.2.12 / OpenAPI 3.1
* @return min contains
*/
@OpenAPI31
int minContains() default 0;

/**
* Provides unevaluted items to this schema
*
* @since 2.2.12 / OpenAPI 3.1
* @return unevaluated items
*/
@OpenAPI31
Schema unevaluatedItems() default @Schema;

/**
* Provides prefix items to this schema
*
* @since 2.2.12 / OpenAPI 3.1
* @return prefixItems
*/
@OpenAPI31
Schema[] prefixItems() default {};
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.swagger.v3.oas.annotations.media;

import io.swagger.v3.oas.annotations.OpenAPI31;
import io.swagger.v3.oas.annotations.extensions.Extension;

import java.lang.annotation.ElementType;
Expand Down Expand Up @@ -84,4 +85,90 @@
*/
Extension[] extensions() default {};

/**
* Subschemas to be applied for a given condition.
*
* @since 2.2.12 / OpenAPI 3.1
* @return list of dependent schemas.
*/
@OpenAPI31
DependentSchema[] dependentSchemas() default {};

/**
* Provides the content schema related to this schema
*
* @since 2.2.12 / OpenAPI 3.1
* @return content schema
*/
@OpenAPI31
Schema contentSchema() default @Schema();

/**
* Provides property names related to this schema
*
* @since 2.2.12 / OpenAPI 3.1
* @return proeprty names
*/
@OpenAPI31
Schema propertyNames() default @Schema();

/**
* Provides the if sub schema related to this schema
*
* @since 2.2.12 / OpenAPI 3.1
* @return if schema
*/
@OpenAPI31
Schema _if() default @Schema();

/**
* Provides the then sub schema related to this schema
*
* @since 2.2.12 / OpenAPI 3.1
* @return then schema
*/
@OpenAPI31
Schema _then() default @Schema();

/**
* Provides the else sub schema related to this schema
*
* @since 2.2.12 / OpenAPI 3.1
* @return else schema
*/
@OpenAPI31
Schema _else() default @Schema();

/**
* Set schemas to validate according a given condition.
*
* @since 2.2.12 / OpenAPI 3.1
* @return not schema to be validated
**/
Schema not() default @Schema();

/**
* Provides the oneOf sub schemas related to this schema.
*
* @since 2.2.12 / OpenAPI 3.1
* @return oneOf sub schemas
**/
Schema[] oneOf() default {};

/**
* Provides the anyOf sub schemas related to this schema.
*
* @since 2.2.12 / OpenAPI 3.1
* @return anyOf sub schemas
**/
Schema[] anyOf() default {};

/**
* Provides the allOf sub schemas related to this schema..
*
* @since 2.2.12 / OpenAPI 3.1
* @return allOf sub schemas
**/
Schema[] allOf() default {};

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package io.swagger.v3.oas.annotations.media;

import io.swagger.v3.oas.annotations.OpenAPI31;

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

import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.ElementType.TYPE;

/**
* The annotation may be used to define dependent schemas for an Object Schema
*
* @see Schema
*
* @since 2.2.12 / OpenAPI 3.1
**/
@Target({FIELD, METHOD, PARAMETER, TYPE, ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Inherited
@Repeatable(DependentRequiredMap.class)
@OpenAPI31
public @interface DependentRequired {
/**
* The name.
*
* @return the name
**/
String name() default "";

/**
* The values of the dependent schema.
*
* @return the schema
**/
String[] value() default {};

}
Loading