Skip to content

Commit

Permalink
Merge pull request springdoc#1718 from shardt68/javadoc-_of_JsonUnwra…
Browse files Browse the repository at this point in the history
…pped_fields_not_set

fixes springdoc#1717 javadoc of JsonUnwrapped fields not set
  • Loading branch information
bnasslahsen committed Jul 15, 2022
2 parents af47269 + 14a463d commit 5bd85e1
Show file tree
Hide file tree
Showing 6 changed files with 210 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import java.util.Map;
import java.util.Optional;

import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.annotation.JsonUnwrapped;
import com.fasterxml.jackson.databind.JavaType;
import io.swagger.v3.core.converter.AnnotatedType;
import io.swagger.v3.core.converter.ModelConverter;
Expand Down Expand Up @@ -125,6 +127,8 @@ private void setJavadocDescription(Class<?> cls, List<Field> fields, Schema exis
stringSchemaEntry.getValue().setDescription(fieldJavadoc);
});
});
fields.stream().filter(f -> f.isAnnotationPresent(JsonUnwrapped.class))
.forEach(f -> setJavadocDescription(f.getType(), FieldUtils.getAllFieldsList(f.getType()), existingSchema));

}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
*
* * 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.app165;

/**
* The type Bar.
*/
public class Bar {
/**
* The BarField.
*/
public String barField = "bar";
}
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.app165;

import com.fasterxml.jackson.annotation.JsonUnwrapped;

/**
* The type Foo.
*/
public class Foo {
/**
* The Bar.
*/
@JsonUnwrapped
public Bar bar;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
*
* * 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.app165;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.v3.oas.annotations.parameters.RequestBody;

/**
* The type Hello controller.
*/
@RestController("/api")
public class HelloController {

/**
* Process foo.
*
* @param a the a
* @return the foo
*/
@PostMapping
public Foo process(@RequestBody Foo a) {
return a;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
*
* * 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.app165;

import org.springframework.boot.autoconfigure.SpringBootApplication;

import test.org.springdoc.api.AbstractSpringDocTest;

/**
* The type Spring doc app 165 test.
*/
public class SpringDocApp165Test extends AbstractSpringDocTest {

/**
* The type Spring doc test app.
*/
@SpringBootApplication
static class SpringDocTestApp {
}
}
67 changes: 67 additions & 0 deletions springdoc-openapi-javadoc/src/test/resources/results/app165.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"openapi": "3.0.1",
"info": {
"title": "OpenAPI definition",
"version": "v0"
},
"servers": [
{
"url": "http://localhost",
"description": "Generated server url"
}
],
"tags": [
{
"name": "hello-controller",
"description": "The type Hello controller."
}
],
"paths": {
"/": {
"post": {
"tags": [
"hello-controller"
],
"summary": "Process foo.",
"description": "Process foo.",
"operationId": "process",
"requestBody": {
"description": "the a",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Foo"
}
}
}
},
"responses": {
"200": {
"description": "the foo",
"content": {
"*/*": {
"schema": {
"$ref": "#/components/schemas/Foo"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"Foo": {
"type": "object",
"properties": {
"barField": {
"type": "string",
"description": "The BarField."
}
},
"description": "The type Foo."
}
}
}
}

0 comments on commit 5bd85e1

Please sign in to comment.