是否可以使用 OpenAPI 来描述 HATEOAS REST API?
当我以HAL格式描述 API 时,我需要为其定义三种模式(一种用于请求有效负载,一种用于收集资源,一种用于项目资源)。例如:
components:
schemas:
Link:
type: object
properties:
href:
type: string
hreflang:
type: string
title:
type: string
type:
type: string
deprecation:
type: string
profile:
type: string
name:
type: string
templated:
type: boolean
Links:
type: object
discriminator:
propertyName: _links
properties:
_links:
type: object
additionalProperties:
type: string
$ref: "#/components/schemas/Link"
CollectionModel:
type: object
discriminator:
propertyName: _embedded
properties:
_embedded:
type: object
_links:
type: object
properties:
self:
type: string
profile:
type: string
search:
type: string
CollectionModel_Foo:
type: …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Kotlin 中的注释定义一个简单的 Hibernate 映射。但是我的多对多关系没有按预期工作。在 IntelliJ IDEA 中导致以下错误:
'一对多'/'多对多'属性值类型不应该是'?扩展 PersonAddress/Person'
我的代码库:
@Entity
open class Person(
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
var id: Long = 0L,
@OneToMany(mappedBy = "person")
var addresses: Set<PersonAddress> = setOf() //Fail
)
@Entity
open class Address(
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
var id: Long = 0L,
@OneToMany(mappedBy = "address")
var persons: Set<PersonAddress> = setOf() //Fail
)
@Entity
open class PersonAddress(
@Id
var id: Long,
@ManyToOne
@JoinColumn(name = "person_id")
var person: Person,
@ManyToOne
@JoinColumn(name = "address_id")
var address: Address
) …Run Code Online (Sandbox Code Playgroud) 我想集成 spring boot maven 插件功能来构建 OCI 映像并将其发布到远程存储库
我想使用以下插件配置:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<image>
<name>${docker.image.prefix}/${project.artifactId}:${project.version}</name>
</image>
</configuration>
<executions>
<execution>
<goals>
<goal>build-image</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
现在我想docker.publishRegistry通过命令行传递变量。
我尝试通过-Ddocker.publishRegistry.username属性传递参数,但没有成功。
当您查看插件的源代码时,Docker没有为其分配 Parameter 属性:
/**
* Alias for {@link Image#publish} to support configuration via command-line property.
*/
@Parameter(property = "spring-boot.build-image.publish", readonly = true)
Boolean publish;
/**
* Docker configuration options.
* @since 2.4.0
*/
@Parameter
private Docker docker;
Run Code Online (Sandbox Code Playgroud)
所以我想不可能通过命令行定义这个参数,是吗?
目前,我正在通过全局 Maven 属性定义属性并在docker范围内重用它们。我的 pom.xml: …
我设置了一个简单的测试控制器:
@Controller("/test")
public class SampleController {
@Get(value = "1", produces = MediaType.TEXT_PLAIN)
public String helloWorld1() {
return "Hello, World!";
}
@Get(value = "2", produces = MediaType.TEXT_PLAIN)
public HttpResponse<String> helloWorld2() {
return HttpResponse.ok("Hello, World!");
}
}
Run Code Online (Sandbox Code Playgroud)
我在单元测试中使用低级 HTTPClient,如下所示:
@MicronautTest
public class SampleControllerTest {
@Inject
EmbeddedServer server;
@Inject
@Client("/test")
HttpClient client;
@Test
void shouldReturnHelloWorld1_1() {
HttpResponse<String> response = client.toBlocking().exchange(HttpRequest.GET("/1").accept(
MediaType.TEXT_PLAIN));
assertEquals(200, response.code());
assertEquals("Hello, World!", response.body());
}
@Test
void shouldReturnHelloWorld1_2() {
String response = client.toBlocking().retrieve(HttpRequest.GET("/1").accept(MediaType.TEXT_PLAIN));
assertEquals("Hello, World!", response);
}
@Test
void shouldReturnHelloWorld2() { …Run Code Online (Sandbox Code Playgroud)