Skip to content

Commit

Permalink
Add test.
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima committed Feb 4, 2022
1 parent bb89c0e commit e6e5f4f
Show file tree
Hide file tree
Showing 5 changed files with 177 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package test.org.springdoc.api.app181;

import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema;

public class AbstractParameterObject<T> {

int primitiveBaseField;

T genericField;

public int getPrimitiveBaseField() {
return primitiveBaseField;
}

public void setPrimitiveBaseField(int primitiveBaseField) {
this.primitiveBaseField = primitiveBaseField;
}

public T getGenericField() {
return genericField;
}

public void setGenericField(T genericField) {
this.genericField = genericField;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package test.org.springdoc.api.app181;

public class ConcreteParameterObject extends AbstractParameterObject<String> {

int primitiveConcreteField;

public int getPrimitiveConcreteField() {
return primitiveConcreteField;
}

public void setPrimitiveConcreteField(int primitiveConcreteField) {
this.primitiveConcreteField = primitiveConcreteField;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
*
* * 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.app181;

import org.springdoc.api.annotations.ParameterObject;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {

@GetMapping( "/test1")
public ResponseEntity<String> sayHello( @ParameterObject final ConcreteParameterObject test) {
System.out.println("Field B = " + test);
return new ResponseEntity<String>("{\"Say\": \"Hello\"}", HttpStatus.OK);
}


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


import test.org.springdoc.api.AbstractSpringDocTest;

import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
* Tests Spring meta-annotations as method parameters
*/
public class SpringDocApp181Test extends AbstractSpringDocTest {

@SpringBootApplication
static class SpringDocTestApp {}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"openapi": "3.0.1",
"info": {
"title": "OpenAPI definition",
"version": "v0"
},
"servers": [
{
"url": "http://localhost",
"description": "Generated server url"
}
],
"paths": {
"/test1": {
"get": {
"tags": [
"hello-controller"
],
"operationId": "sayHello",
"parameters": [
{
"name": "primitiveConcreteField",
"in": "query",
"required": false,
"schema": {
"type": "integer",
"format": "int32"
}
},
{
"name": "primitiveBaseField",
"in": "query",
"required": false,
"schema": {
"type": "integer",
"format": "int32"
}
},
{
"name": "genericField",
"in": "query",
"required": false,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK",
"content": {
"*/*": {
"schema": {
"type": "string"
}
}
}
}
}
}
}
},
"components": {}
}

0 comments on commit e6e5f4f

Please sign in to comment.