-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Enhance OpenAPI for cosid-proxy (#399)
- Loading branch information
Showing
24 changed files
with
261 additions
and
84 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
cosid-core/src/test/java/me/ahoo/cosid/accessor/NotFoundCosIdAccessorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)]. | ||
* 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 | ||
* http://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 me.ahoo.cosid.accessor; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.*; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
class NotFoundCosIdAccessorTest { | ||
@Test | ||
public void getIdDefinition() { | ||
assertThat(CosIdAccessor.NOT_FOUND.getIdDefinition(), nullValue()); | ||
} | ||
|
||
@Test | ||
public void getIdGenerator() { | ||
assertThat(CosIdAccessor.NOT_FOUND.getIdGenerator(), nullValue()); | ||
} | ||
|
||
@Test | ||
public void getIdField() { | ||
assertThat(CosIdAccessor.NOT_FOUND.getIdField(), nullValue()); | ||
} | ||
|
||
@Test | ||
public void getId() { | ||
assertThat(CosIdAccessor.NOT_FOUND.getId(new Object()), nullValue()); | ||
} | ||
|
||
@Test | ||
public void setId() { | ||
CosIdAccessor.NOT_FOUND.setId(new Object(), new Object()); | ||
} | ||
|
||
@Test | ||
public void ensureId() { | ||
assertThat(CosIdAccessor.NOT_FOUND.ensureId(new Object()), equalTo(false)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
cosid-core/src/test/java/me/ahoo/cosid/annotation/entity/IntIdEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)]. | ||
* 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 | ||
* http://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 me.ahoo.cosid.annotation.entity; | ||
|
||
import me.ahoo.cosid.annotation.CosId; | ||
|
||
/** | ||
* @author ahoo wang | ||
*/ | ||
public class IntIdEntity { | ||
@CosId | ||
private int id; | ||
|
||
public int getId() { | ||
return id; | ||
} | ||
|
||
public void setId(int id) { | ||
this.id = id; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...y-server/src/main/java/me/ahoo/cosid/proxy/server/configuration/SwaggerConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)]. | ||
* 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 | ||
* http://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 me.ahoo.cosid.proxy.server.configuration; | ||
|
||
import com.google.common.base.MoreObjects; | ||
import io.swagger.v3.oas.models.info.Contact; | ||
import io.swagger.v3.oas.models.info.Info; | ||
import io.swagger.v3.oas.models.info.License; | ||
import org.springdoc.core.customizers.OpenApiCustomizer; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class SwaggerConfiguration { | ||
|
||
@Bean | ||
public OpenApiCustomizer openApiCustomizer() { | ||
var version = MoreObjects.firstNonNull(getClass().getPackage().getImplementationVersion(), "2.3.0"); | ||
return openApi -> { | ||
var info = new Info() | ||
.title("CosId Proxy Server") | ||
.description("Universal, flexible, high-performance distributed ID generator.") | ||
.contact(new Contact().name("Ahoo Wang").url("https://github.com/Ahoo-Wang/CosId")) | ||
.license(new License().url("https://github.com/Ahoo-Wang/CosId/blob/main/LICENSE").name("Apache 2.0")) | ||
.version(version); | ||
openApi.info(info); | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.