Skip to content

Commit bd93219

Browse files
Joze RIHTARSICJoze RIHTARSIC
Joze RIHTARSIC
authored and
Joze RIHTARSIC
committed
Upgrade to 3.1.0 for the pilot project
2 parents f6e79c1 + 0ef7a7d commit bd93219

File tree

97 files changed

+1716
-543
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+1716
-543
lines changed

README.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
**NOTE:** THIS IS FORK from https://github.com/swagger-api/swagger-core and it intended only for testing and piloting REST related projects
2-
For production use the original libraries!!!!
3-
4-
5-
6-
71
# Swagger Core <img src="https://raw.githubusercontent.com/swagger-api/swagger.io/wordpress/images/assets/SW-logo-clr.png" height="50" align="right">
82

93
**NOTE:** If you're looking for Swagger Core 1.5.X and OpenAPI 2.0, please refer to [1.5 branch](https://github.com/swagger-api/swagger-core/tree/1.5).
@@ -27,7 +21,8 @@ The OpenAPI Specification has undergone several revisions since initial creation
2721

2822
Swagger core Version | Release Date | OpenAPI Spec compatibility | Notes | Status
2923
------------------------- | ------------ | -------------------------- | ----- | ----
30-
2.1.9 (**current stable**)| 2021-04-20 | 3.0 | [tag v2.1.9](https://github.com/swagger-api/swagger-core/tree/v2.1.9) | Supported
24+
2.1.10 (**current stable**)| 2021-06-28 | 3.0 | [tag v2.1.10](https://github.com/swagger-api/swagger-core/tree/v2.1.10) | Supported
25+
2.1.9 | 2021-04-20 | 3.0 | [tag v2.1.9](https://github.com/swagger-api/swagger-core/tree/v2.1.9) | Supported
3126
2.1.8 | 2021-04-18 | 3.0 | [tag v2.1.8](https://github.com/swagger-api/swagger-core/tree/v2.1.8) | Supported
3227
2.1.7 | 2021-02-18 | 3.0 | [tag v2.1.7](https://github.com/swagger-api/swagger-core/tree/v2.1.7) | Supported
3328
2.1.6 | 2020-12-04 | 3.0 | [tag v2.1.6](https://github.com/swagger-api/swagger-core/tree/v2.1.6) | Supported
@@ -80,7 +75,7 @@ You need the following installed and available in your $PATH:
8075
* Jackson 2.4.5 or greater
8176

8277

83-
### To build from source (currently 2.1.10-ISA2-SNAPSHOT)
78+
### To build from source (currently 2.1.11-SNAPSHOT)
8479
```
8580
# first time building locally
8681
mvn -N

modules/swagger-annotations/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<groupId>io.github.jrihtarsic.swagger</groupId>
55
<artifactId>swagger-project</artifactId>
6-
<version>2.1.10-OA3.1-SNAPSHOT</version>
6+
<version>2.1.11-OA3.1-SNAPSHOT</version>
77
<relativePath>../..</relativePath>
88
</parent>
99
<modelVersion>4.0.0</modelVersion>

modules/swagger-annotations/src/main/java/io/swagger/v3/oas/annotations/media/PatternProperties.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
package io.swagger.v3.oas.annotations.media;
1818

19-
import io.swagger.v3.oas.annotations.responses.ApiResponse;
20-
2119
import java.lang.annotation.Inherited;
2220
import java.lang.annotation.Retention;
2321
import java.lang.annotation.RetentionPolicy;

modules/swagger-annotations/src/main/java/io/swagger/v3/oas/annotations/media/PatternProperty.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package io.swagger.v3.oas.annotations.media;
1818

19-
import java.lang.annotation.ElementType;
2019
import java.lang.annotation.Inherited;
2120
import java.lang.annotation.Repeatable;
2221
import java.lang.annotation.Retention;

modules/swagger-core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<groupId>io.github.jrihtarsic.swagger</groupId>
55
<artifactId>swagger-project</artifactId>
6-
<version>2.1.10-OA3.1-SNAPSHOT</version>
6+
<version>2.1.11-OA3.1-SNAPSHOT</version>
77
<relativePath>../..</relativePath>
88
</parent>
99
<modelVersion>4.0.0</modelVersion>

modules/swagger-core/src/main/java/io/swagger/v3/core/jackson/ModelResolver.java

Lines changed: 2 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@
3333
import io.swagger.v3.core.util.AnnotationsUtils;
3434
import io.swagger.v3.core.util.Constants;
3535
import io.swagger.v3.core.util.Json;
36-
import io.swagger.v3.core.util.Json31;
3736
import io.swagger.v3.core.util.ObjectMapperFactory;
38-
import io.swagger.v3.core.util.OpenAPISchema2JsonSchema;
3937
import io.swagger.v3.core.util.OptionalUtils;
4038
import io.swagger.v3.core.util.PrimitiveType;
4139
import io.swagger.v3.core.util.ReflectionUtils;
@@ -115,11 +113,6 @@ public class ModelResolver extends AbstractModelConverter implements ModelConver
115113
*/
116114
public static boolean enumsAsRef = System.getProperty(SET_PROPERTY_OF_ENUMS_AS_REF) != null;
117115

118-
/**
119-
* @since 2.1.8
120-
*/
121-
protected OpenAPISchema2JsonSchema jsonSchemaProcessor = new OpenAPISchema2JsonSchema();
122-
123116
public ModelResolver(ObjectMapper mapper) {
124117
super(mapper);
125118
}
@@ -204,15 +197,11 @@ public Schema resolve(AnnotatedType annotatedType, ModelConverterContext context
204197
if (resolvedSchemaAnnotation != null &&
205198
StringUtils.isNotEmpty(resolvedSchemaAnnotation.ref())) {
206199
if (resolvedArrayAnnotation == null) {
207-
Schema result = new Schema().$ref(resolvedSchemaAnnotation.ref()).name(name);
208-
jsonSchemaProcessor.process(result);
209200
return new Schema().$ref(resolvedSchemaAnnotation.ref()).name(name);
210201
} else {
211202
ArraySchema schema = new ArraySchema();
212203
resolveArraySchema(annotatedType, schema, resolvedArrayAnnotation);
213-
schema.items(new Schema().$ref(resolvedSchemaAnnotation.ref()).name(name));
214-
jsonSchemaProcessor.process(schema);
215-
return schema;
204+
return schema.items(new Schema().$ref(resolvedSchemaAnnotation.ref()).name(name));
216205
}
217206
}
218207

@@ -264,7 +253,6 @@ public Schema resolve(AnnotatedType annotatedType, ModelConverterContext context
264253
}
265254
}
266255
schema.setItems(innerSchema);
267-
jsonSchemaProcessor.process(schema);
268256
return schema;
269257
} else {
270258
Schema implSchema = context.resolve(aType);
@@ -276,9 +264,6 @@ public Schema resolve(AnnotatedType annotatedType, ModelConverterContext context
276264
} else if (implSchema != null && implSchema.get$ref() != null) {
277265
implSchema = new Schema().$ref(StringUtils.isNotEmpty(implSchema.get$ref()) ? implSchema.get$ref() : implSchema.getName());
278266
}
279-
if (implSchema != null) {
280-
jsonSchemaProcessor.process(implSchema);
281-
}
282267
return implSchema;
283268
}
284269
}
@@ -326,7 +311,6 @@ public Schema resolve(AnnotatedType annotatedType, ModelConverterContext context
326311
}
327312
model = new GeneratorWrapper().processJsonIdentity(annotatedType, context, _mapper, jsonIdentityInfo, jsonIdentityReference);
328313
if (model != null) {
329-
jsonSchemaProcessor.process(model);
330314
return model;
331315
}
332316
}
@@ -357,19 +341,14 @@ public Schema resolve(AnnotatedType annotatedType, ModelConverterContext context
357341
ArraySchema schema = new ArraySchema();
358342
resolveArraySchema(annotatedType, schema, resolvedArrayAnnotation);
359343
schema.setItems(model);
360-
jsonSchemaProcessor.process(schema);
361344
return schema;
362345
}
363346
if (type.isEnumType() && shouldResolveEnumAsRef(resolvedSchemaAnnotation)) {
364347
// Store off the ref and add the enum as a top-level model
365-
jsonSchemaProcessor.process(model);
366348
context.defineModel(name, model, annotatedType, null);
367349
// Return the model as a ref only property
368350
model = new Schema().$ref(Components.COMPONENTS_SCHEMAS_REF + name);
369351
}
370-
if (model != null) {
371-
jsonSchemaProcessor.process(model);
372-
}
373352
return model;
374353
}
375354

@@ -388,7 +367,6 @@ public Schema resolve(AnnotatedType annotatedType, ModelConverterContext context
388367
Schema resolvedModel = context.resolve(annotatedType);
389368
if (resolvedModel != null) {
390369
if (name != null && name.equals(resolvedModel.getName())) {
391-
jsonSchemaProcessor.process(resolvedModel);
392370
return resolvedModel;
393371
}
394372
}
@@ -406,11 +384,7 @@ public Schema resolve(AnnotatedType annotatedType, ModelConverterContext context
406384
.propertyName(annotatedType.getPropertyName())
407385
.ctxAnnotations(annotatedType.getCtxAnnotations())
408386
.skipOverride(true);
409-
Schema result = context.resolve(aType);
410-
if (result != null) {
411-
jsonSchemaProcessor.process(result);
412-
}
413-
return result;
387+
return context.resolve(aType);
414388
}
415389

416390
List<Class<?>> composedSchemaReferencedClasses = getComposedSchemaReferencedClasses(type.getRawClass(), annotatedType.getCtxAnnotations(), resolvedSchemaAnnotation);
@@ -526,9 +500,6 @@ public Schema resolve(AnnotatedType annotatedType, ModelConverterContext context
526500
AnnotatedType aType = OptionalUtils.unwrapOptional(annotatedType);
527501
if (aType != null) {
528502
model = context.resolve(aType);
529-
if (model != null) {
530-
jsonSchemaProcessor.process(model);
531-
}
532503
return model;
533504
} else {
534505
model = new Schema()
@@ -539,7 +510,6 @@ public Schema resolve(AnnotatedType annotatedType, ModelConverterContext context
539510

540511
if (!type.isContainerType() && StringUtils.isNotBlank(name)) {
541512
// define the model here to support self/cyclic referencing of models
542-
jsonSchemaProcessor.process(model);
543513
context.defineModel(name, model, annotatedType, null);
544514
}
545515

@@ -766,7 +736,6 @@ public Schema resolve(AnnotatedType annotatedType, ModelConverterContext context
766736
* available for modification by resolveSubtypes, when their parents are created.
767737
*/
768738
if (!type.isContainerType() && StringUtils.isNotBlank(name)) {
769-
jsonSchemaProcessor.process(model);
770739
context.defineModel(name, model, annotatedType, null);
771740
}
772741

@@ -897,7 +866,6 @@ public Schema resolve(AnnotatedType annotatedType, ModelConverterContext context
897866

898867
if (!type.isContainerType() && StringUtils.isNotBlank(name)) {
899868
// define the model here to support self/cyclic referencing of models
900-
jsonSchemaProcessor.process(model);
901869
context.defineModel(name, model, annotatedType, null);
902870
}
903871

@@ -917,7 +885,6 @@ public Schema resolve(AnnotatedType annotatedType, ModelConverterContext context
917885
ArraySchema schema = new ArraySchema();
918886
schema.setItems(model);
919887
resolveArraySchema(annotatedType, schema, resolvedArrayAnnotation);
920-
jsonSchemaProcessor.process(schema);
921888
return schema;
922889
} else {
923890
if (model instanceof ArraySchema) {
@@ -1421,8 +1388,6 @@ private boolean resolveSubtypes(Schema model, BeanDescription bean, ModelConvert
14211388
composedSchema = (ComposedSchema) new ComposedSchema()
14221389
.title(subtypeModel.getTitle())
14231390
.name(subtypeModel.getName())
1424-
.id(subtypeModel.get$id())
1425-
.schema(subtypeModel.get$schema())
14261391
.deprecated(subtypeModel.getDeprecated())
14271392
.additionalProperties(subtypeModel.getAdditionalProperties())
14281393
.description(subtypeModel.getDescription())
@@ -1478,7 +1443,6 @@ private boolean resolveSubtypes(Schema model, BeanDescription bean, ModelConvert
14781443
// replace previous schema..
14791444
Class<?> currentType = subtype.getType();
14801445
if (StringUtils.isNotBlank(composedSchema.getName())) {
1481-
jsonSchemaProcessor.process(composedSchema);
14821446
context.defineModel(composedSchema.getName(), composedSchema, new AnnotatedType().type(currentType), null);
14831447
}
14841448

@@ -1576,19 +1540,6 @@ protected String resolveFormat(Annotated a, Annotation[] annotations, io.swagger
15761540
return null;
15771541
}
15781542

1579-
protected String resolveId(Annotated a, Annotation[] annotations, io.swagger.v3.oas.annotations.media.Schema schema) {
1580-
if (schema != null && StringUtils.isNotBlank(schema.id())) {
1581-
return schema.id();
1582-
}
1583-
return null;
1584-
}
1585-
protected String resolveSchema(Annotated a, Annotation[] annotations, io.swagger.v3.oas.annotations.media.Schema schema) {
1586-
if (schema != null && StringUtils.isNotBlank(schema.schema())) {
1587-
return schema.schema();
1588-
}
1589-
return null;
1590-
}
1591-
15921543
protected Map<String, Schema> resolvePatternProperties(JavaType a, Annotation[] annotations, ModelConverterContext context) {
15931544

15941545
final Map<String, PatternProperty> propList = new LinkedHashMap<>();
@@ -2168,14 +2119,6 @@ protected void resolveSchemaMembers(Schema schema, Annotated a, Annotation[] ann
21682119
if (StringUtils.isNotBlank(title)) {
21692120
schema.title(title);
21702121
}
2171-
String id = resolveId(a, annotations, schemaAnnotation);
2172-
if (StringUtils.isNotBlank(id)) {
2173-
schema.id(id);
2174-
}
2175-
String schemaUrl = resolveSchema(a, annotations, schemaAnnotation);
2176-
if (StringUtils.isNotBlank(schemaUrl)) {
2177-
schema.schema(schemaUrl);
2178-
}
21792122
String format = resolveFormat(a, annotations, schemaAnnotation);
21802123
if (StringUtils.isNotBlank(format) && StringUtils.isBlank(schema.getFormat())) {
21812124
schema.format(format);

modules/swagger-core/src/main/java/io/swagger/v3/core/jackson/Schema31Serializer.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import com.fasterxml.jackson.databind.SerializerProvider;
77
import com.fasterxml.jackson.databind.ser.ResolvableSerializer;
88
import io.swagger.v3.oas.models.media.Schema;
9-
import org.apache.commons.lang3.StringUtils;
109

1110
import java.io.IOException;
1211

@@ -30,9 +29,13 @@ public void serialize(
3029
Schema value, JsonGenerator jgen, SerializerProvider provider)
3130
throws IOException {
3231

32+
defaultSerializer.serialize(value, jgen, provider);
33+
34+
/*
3335
// handle ref schema serialization skipping all other props
3436
if (value.getJsonSchema() != null) {
3537
jgen.writeObject(value.getJsonSchema());
3638
}
39+
*/
3740
}
3841
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
package io.swagger.v3.core.jackson.mixin;
22

33
import com.fasterxml.jackson.annotation.JsonFormat;
4+
import com.fasterxml.jackson.annotation.JsonIgnore;
5+
6+
import java.util.Map;
47

58
public abstract class DateSchemaMixin {
69

710
@JsonFormat (shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
811
public abstract Object getExample();
12+
13+
@JsonIgnore
14+
public abstract Object getJsonSchemaImpl();
15+
16+
@JsonIgnore
17+
public abstract Map<String, Object> getJsonSchema();
918
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package io.swagger.v3.core.jackson.mixin;
2+
3+
import com.fasterxml.jackson.annotation.JsonAnyGetter;
4+
import com.fasterxml.jackson.annotation.JsonAnySetter;
5+
import com.fasterxml.jackson.annotation.JsonIgnore;
6+
import com.fasterxml.jackson.annotation.JsonInclude;
7+
8+
import java.util.Map;
9+
10+
public abstract class ExampleMixin {
11+
12+
@JsonAnyGetter
13+
public abstract Map<String, Object> getExtensions();
14+
15+
@JsonAnySetter
16+
public abstract void addExtension(String name, Object value);
17+
18+
@JsonInclude(JsonInclude.Include.CUSTOM)
19+
public abstract Object getValue();
20+
21+
@JsonIgnore
22+
public abstract boolean getValueSetFlag();
23+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package io.swagger.v3.core.jackson.mixin;
2+
3+
import com.fasterxml.jackson.annotation.JsonAnyGetter;
4+
import com.fasterxml.jackson.annotation.JsonAnySetter;
5+
import com.fasterxml.jackson.annotation.JsonIgnore;
6+
import com.fasterxml.jackson.annotation.JsonInclude;
7+
8+
import java.util.Map;
9+
10+
public abstract class MediaTypeMixin {
11+
12+
@JsonAnyGetter
13+
public abstract Map<String, Object> getExtensions();
14+
15+
@JsonAnySetter
16+
public abstract void addExtension(String name, Object value);
17+
18+
@JsonIgnore
19+
public abstract boolean getExampleSetFlag();
20+
21+
@JsonInclude(JsonInclude.Include.CUSTOM)
22+
public abstract Object getExample();
23+
}

0 commit comments

Comments
 (0)