Skip to content

Commit

Permalink
Merge branch 'tdevilleduc-property-resolver'
Browse files Browse the repository at this point in the history
  • Loading branch information
bnasslahsen committed Mar 3, 2020
2 parents 452aa82 + 8f8381c commit 5c0a7b5
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,19 @@ public class GenericParameterBuilder {

private final LocalVariableTableParameterNameDiscoverer localSpringDocParameterNameDiscoverer;
private final IgnoredParameterAnnotations ignoredParameterAnnotations;
private final PropertyResolverUtils propertyResolverUtils;
private static final List<Class<?>> FILE_TYPES = new ArrayList<>();

static {
FILE_TYPES.add(MultipartFile.class);
}

public GenericParameterBuilder(LocalVariableTableParameterNameDiscoverer localSpringDocParameterNameDiscoverer, IgnoredParameterAnnotations ignoredParameterAnnotations) {
public GenericParameterBuilder(LocalVariableTableParameterNameDiscoverer localSpringDocParameterNameDiscoverer,
IgnoredParameterAnnotations ignoredParameterAnnotations,
PropertyResolverUtils propertyResolverUtils) {
this.localSpringDocParameterNameDiscoverer = localSpringDocParameterNameDiscoverer;
this.ignoredParameterAnnotations = ignoredParameterAnnotations;
this.propertyResolverUtils = propertyResolverUtils;
}

Parameter mergeParameter(List<Parameter> existingParamDoc, Parameter paramCalcul) {
Expand Down Expand Up @@ -132,10 +136,10 @@ Parameter buildParameterFromDoc(io.swagger.v3.oas.annotations.Parameter paramete
Components components, JsonView jsonView) {
Parameter parameter = new Parameter();
if (StringUtils.isNotBlank(parameterDoc.description())) {
parameter.setDescription(parameterDoc.description());
parameter.setDescription(propertyResolverUtils.resolve(parameterDoc.description()));
}
if (StringUtils.isNotBlank(parameterDoc.name())) {
parameter.setName(parameterDoc.name());
parameter.setName(propertyResolverUtils.resolve(parameterDoc.name()));
}
if (StringUtils.isNotBlank(parameterDoc.in().toString())) {
parameter.setIn(parameterDoc.in().toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public OperationBuilder(GenericParameterBuilder parameterBuilder, RequestBodyBui
public OpenAPI parse(Components components, io.swagger.v3.oas.annotations.Operation apiOperation,
Operation operation, OpenAPI openAPI, MethodAttributes methodAttributes) {
if (StringUtils.isNotBlank(apiOperation.summary())) {
operation.setSummary(apiOperation.summary());
operation.setSummary(propertyResolverUtils.resolve(apiOperation.summary()));
}
if (StringUtils.isNotBlank(apiOperation.description())) {
operation.setDescription(propertyResolverUtils.resolve(apiOperation.description()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,10 @@ public GenericReturnTypeParser genericReturnTypeParser() {
}

@Bean
public GenericParameterBuilder parameterBuilder(LocalVariableTableParameterNameDiscoverer localSpringDocParameterNameDiscoverer, IgnoredParameterAnnotations ignoredParameterAnnotations) {
return new GenericParameterBuilder(localSpringDocParameterNameDiscoverer, ignoredParameterAnnotations);
public GenericParameterBuilder parameterBuilder(LocalVariableTableParameterNameDiscoverer localSpringDocParameterNameDiscoverer,
IgnoredParameterAnnotations ignoredParameterAnnotations,
PropertyResolverUtils propertyResolverUtils) {
return new GenericParameterBuilder(localSpringDocParameterNameDiscoverer, ignoredParameterAnnotations, propertyResolverUtils);
}

static class ConditionOnCacheOrGroupedOpenApi extends AnyNestedCondition {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package test.org.springdoc.api.app95;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/persons")
public class HelloController {

@GetMapping
@Operation(summary = "${test.app95.operation.persons.summary}",
description = "${test.app95.operation.persons.description}")
public void persons(@Parameter(description = "${test.app95.param.name.description}") String name) {

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
*
* * Copyright 2019-2020 the original author or authors.
* *
* * 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
* *
* * https://www.apache.org/licenses/LICENSE-2.0
* *
* * 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 test.org.springdoc.api.app95;


import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.test.context.ActiveProfiles;
import test.org.springdoc.api.AbstractSpringDocTest;

@ActiveProfiles("95")
public class SpringDocApp95Test extends AbstractSpringDocTest {

@SpringBootApplication
static class SpringDocTestApp {}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
test:
app95:
operation:
persons:
summary: Summary of operation persons
description: Description of operation persons
param:
name:
description: Description of parameter name
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"openapi": "3.0.1",
"info": {
"title": "OpenAPI definition",
"version": "v0"
},
"servers": [
{
"url": "http://localhost",
"description": "Generated server url"
}
],
"paths": {
"/persons": {
"get": {
"tags": [
"hello-controller"
],
"summary": "Summary of operation persons",
"description": "Description of operation persons",
"operationId": "persons",
"parameters": [
{
"name": "name",
"in": "query",
"description": "Description of parameter name",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "default response"
}
}
}
}
},
"components": {}
}

0 comments on commit 5c0a7b5

Please sign in to comment.