|
1 |
| -package org.springdoc.core.hal; |
| 1 | +/* |
| 2 | + * |
| 3 | + * * Copyright 2019-2020 the original author or authors. |
| 4 | + * * |
| 5 | + * * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | + * * you may not use this file except in compliance with the License. |
| 7 | + * * You may obtain a copy of the License at |
| 8 | + * * |
| 9 | + * * https://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * * |
| 11 | + * * Unless required by applicable law or agreed to in writing, software |
| 12 | + * * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * * See the License for the specific language governing permissions and |
| 15 | + * * limitations under the License. |
| 16 | + * |
| 17 | + */ |
| 18 | + |
| 19 | +package org.springdoc.core.converters; |
| 20 | + |
| 21 | +import java.util.Collection; |
| 22 | +import java.util.Iterator; |
2 | 23 |
|
3 | 24 | import com.fasterxml.jackson.core.JsonGenerator;
|
4 | 25 | import com.fasterxml.jackson.databind.SerializerProvider;
|
|
11 | 32 | import io.swagger.v3.oas.models.media.Schema;
|
12 | 33 | import io.swagger.v3.oas.models.media.StringSchema;
|
13 | 34 |
|
14 |
| -import java.util.Collection; |
15 |
| -import java.util.Iterator; |
16 |
| - |
17 | 35 | /**
|
18 | 36 | * Override resolved schema as there is a custom serializer that converts the data to a map before serializing it.
|
19 | 37 | *
|
20 | 38 | * @see org.springframework.hateoas.mediatype.hal.Jackson2HalModule.HalResourcesSerializer
|
21 | 39 | * @see org.springframework.hateoas.mediatype.hal.Jackson2HalModule.HalResourcesSerializer#serialize(Collection, JsonGenerator, SerializerProvider)
|
22 | 40 | */
|
23 | 41 | public class CollectionModelContentConverter implements ModelConverter {
|
| 42 | + |
| 43 | + private static final CollectionModelContentConverter collectionModelContentConverter = new CollectionModelContentConverter(); |
| 44 | + |
| 45 | + private CollectionModelContentConverter() { } |
| 46 | + |
| 47 | + public static CollectionModelContentConverter getConverter() { |
| 48 | + return collectionModelContentConverter; |
| 49 | + } |
| 50 | + |
24 | 51 | @Override
|
25 | 52 | public Schema<?> resolve(AnnotatedType type, ModelConverterContext context, Iterator<ModelConverter> chain) {
|
26 | 53 | if (chain.hasNext() && type != null && type.getType() instanceof CollectionType
|
|
0 commit comments