Skip to content

Commit

Permalink
Rename crate to speka
Browse files Browse the repository at this point in the history
  • Loading branch information
Flowneee committed Aug 7, 2024
1 parent af90c55 commit a18a30f
Show file tree
Hide file tree
Showing 44 changed files with 73 additions and 62 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ All notable changes to this project will be documented in the changelog of the r
This project follows the [Semantic Versioning standard](https://semver.org/).

For the changelogs of the crates see:
- okapi-operation: [./okapi-operation/CHANGELOG.md](./okapi-operation/CHANGELOG.md)
- okapi-operation-macro: [./okapi-operation-macro/CHANGELOG.md](./okapi-operation-macro/CHANGELOG.md)
- speka: [./speka/CHANGELOG.md](./speka/CHANGELOG.md)
- speka-macro: [./speka-macro/CHANGELOG.md](./speka-macro/CHANGELOG.md)
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[workspace]
resolver = "2"
members = [
"./okapi-operation-macro",
"./okapi-operation",
"./okapi-examples"
"./speka",
"./speka-examples",
"./speka-macro",
]
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# `okapi-operation`
# `speka`

[![Crates.io](https://img.shields.io/crates/v/okapi-operation)](https://crates.io/crates/okapi-operation)
[![docs.rs](https://img.shields.io/docsrs/okapi-operation/latest)](https://docs.rs/okapi-operation/latest)
![CI](https://github.com/Flowneee/okapi-operation/actions/workflows/ci.yml/badge.svg)
[![Crates.io](https://img.shields.io/crates/v/speka)](https://crates.io/crates/speka)
[![docs.rs](https://img.shields.io/docsrs/speka/latest)](https://docs.rs/speka/latest)
![CI](https://github.com/Flowneee/speka/actions/workflows/ci.yml/badge.svg)

Library which allow to generate OpenAPI's operation definitions (using types from `okapi` crate) with procedural
macro `#[openapi]`.
macro `#[openapi]` (formerly named `okapi-operation`, see https://github.com/Flowneee/speka/issues/17).

## Example (with axum-integration feature).

```rust,no_run
use axum::{extract::Query, Json};
use okapi_operation::{axum_integration::*, *};
use speka::{axum_integration::*, *};
use serde::Deserialize;
#[derive(Deserialize, JsonSchema)]
Expand Down Expand Up @@ -70,6 +70,6 @@ fn main() {

* [ ] support examples on MediaType or Parameter (examples supported on types via `JsonSchema` macro)
* [ ] support inferring schemas of parameters from function definitions
* [ ] support for renaming or changing paths to okapi/schemars/okapi-operations in macro
* [ ] support for renaming or changing paths to okapi/schemars/spekas in macro
* [ ] more examples
* [ ] ...
11 changes: 11 additions & 0 deletions publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

set -e
set -x

publish_crate() {
cargo publish -p $1
}

publish_crate speka-macro
publish_crate speka
6 changes: 3 additions & 3 deletions okapi-examples/Cargo.toml → speka-examples/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "okapi-examples"
name = "speka-examples"
version = "0.1.0"
edition = "2021"

Expand All @@ -10,5 +10,5 @@ axum = "0.7"
axum-extra = { version = "0.9", features = ["typed-header"] }
tokio = { version = "1", features = ["full"] }
serde = { version = "1", features = ["derive"] }
okapi-operation = { path = "../okapi-operation", features = ["axum", "yaml"] }
okapi-operation-macro = { path = "../okapi-operation-macro", features = ["axum"] }
speka = { path = "../speka", features = ["axum", "yaml"] }
speka-macro = { path = "../speka-macro", features = ["axum"] }
2 changes: 1 addition & 1 deletion okapi-examples/src/main.rs → speka-examples/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use axum::{extract::Query, Json};
use okapi_operation::{axum_integration::*, *};
use speka::{axum_integration::*, *};
use serde::Deserialize;

#[derive(Deserialize, JsonSchema)]
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This project follows the [Semantic Versioning standard](https://semver.org/).
- Request body detection from function arguments for specific frameworks (i.e. axum);
- `#[body]` attribute as replacement for `#[request_body]` (now considered deprecated);
- Updates `syn` crate to version 2;
- `crate` attribute to support renaming base crate, by default `okapi_operation`;
- `crate` attribute to support renaming base crate, by default `speka`;
- `#[openapi]` macro takes care of reimporting necessary types and traits from base crate.

### Removed
Expand Down
6 changes: 3 additions & 3 deletions okapi-operation-macro/Cargo.toml → speka-macro/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[package]
name = "okapi-operation-macro"
description = "Macro implementation for okapi-operation"
name = "speka-macro"
description = "Macro implementation for speka"
version = "0.2.0"
authors = ["Andrey Kononov flowneee3@gmail.com"]
edition = "2021"
license = "MIT"
keywords = ["rust", "openapi", "swagger", "axum"]
categories = ["web-programming"]
readme = "../README.md"
repository = "https://github.com/Flowneee/okapi-operation"
repository = "https://github.com/Flowneee/speka"

[lib]
proc-macro = true
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ mod security;
// - support for generic functions

static DEFAULT_OPENAPI_ATTRIBUTE_NAME: &str = "openapi";
static DEFAULT_CRATE_NAME: &str = "okapi_operation";
static DEFAULT_CRATE_NAME: &str = "speka";

thread_local! {
pub static MACRO_ATTRIBUTE_NAME: RefCell<String> = RefCell::new(DEFAULT_OPENAPI_ATTRIBUTE_NAME.into());
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions okapi-operation/Cargo.toml → speka/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "okapi-operation"
name = "speka"
description = "Procedural macro for generating OpenAPI operation specification (using okapi)"
version = "0.3.0-rc3"
authors = ["Andrey Kononov flowneee3@gmail.com"]
Expand All @@ -8,10 +8,10 @@ license = "MIT"
keywords = ["rust", "openapi", "swagger", "axum"]
categories = ["web-programming"]
readme = "../README.md"
repository = "https://github.com/Flowneee/okapi-operation"
repository = "https://github.com/Flowneee/speka"

[dependencies]
okapi-operation-macro = { path = "../okapi-operation-macro", version = "0.2", optional = true }
speka-macro = { path = "../speka-macro", version = "0.2", optional = true }

anyhow = "1"
bytes = "1.4"
Expand All @@ -36,10 +36,10 @@ serde = { version = "1", features = ["derive"] }
[features]
default = ["macro"]

macro = ["okapi-operation-macro"]
macro = ["speka-macro"]
yaml = ["serde_yaml"]

axum = ["dep:axum", "paste", "tower", "okapi-operation-macro/axum"]
axum = ["dep:axum", "paste", "tower", "speka-macro/axum"]
# Deprecated, use feature `axum` instead
axum-integration = ["axum"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This is example from root of this crate, but this time with [`axum_integration`]

```no_run
use axum::{extract::Query, Json};
use okapi_operation::{axum_integration::*, *};
use speka::{axum_integration::*, *};
use serde::Deserialize;
#[derive(Deserialize, JsonSchema)]
Expand Down Expand Up @@ -72,7 +72,7 @@ If you need to customize builder template, you can either:

```no_run
use axum::{extract::Query, Json};
use okapi_operation::{axum_integration::*, *};
use speka::{axum_integration::*, *};
use serde::Deserialize;
#[tokio::main]
Expand Down
44 changes: 22 additions & 22 deletions okapi-operation/docs/root.md → speka/docs/root.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `okapi-operation`
# `speka`

- [`okapi-operation`](#-okapi-operation-)
- [`speka`](#-speka-)
* [Example (using axum, but without axum_integration feature)](#example-using-axum-but-without-axum_integration-feature)
* [`openapi` macro](#openapi-macro)
+ [Minimal example](#minimal-example)
Expand Down Expand Up @@ -39,7 +39,7 @@ use axum::{
routing::{get, post},
Json, Router,
};
use okapi_operation::*;
use speka::*;
use serde::Deserialize;
#[derive(Deserialize, JsonSchema)]
Expand Down Expand Up @@ -107,7 +107,7 @@ Since most attributes taken from OpenAPI specification directly, refer to [OpenA
Macro doesn't have any mandatory attributes.

```compile
# use okapi_operation::*;
# use speka::*;
#[openapi]
async fn handler() {}
```
Expand All @@ -119,7 +119,7 @@ All attributes is translated into same fields of [`okapi::openapi3::Operation`].
Tags is provided as single string, which later is separated by comma.

```no_run
# use okapi_operation::*;
# use speka::*;
#[openapi(
summary = "Simple handler",
description = "Simple handler, demonstrating how to use operation attributes",
Expand All @@ -135,7 +135,7 @@ async fn handler() {}
External documentation can be set for operation. It is translated to [`okapi::openapi3::ExternalDocs`].

```no_run
# use okapi_operation::*;
# use speka::*;
#[openapi(
external_docs(
url = "https://example.com",
Expand Down Expand Up @@ -170,7 +170,7 @@ This definition translated to [`okapi::openapi3::Parameter`] with [`okapi::opena
* schema (path, mandatory) - path to type of parameter.

```no_run
# use okapi_operation::*;
# use speka::*;
#[openapi(
parameters(
header(
Expand Down Expand Up @@ -201,7 +201,7 @@ async fn handler() {}
* schema (path, mandatory) - path to type of parameter.

```no_run
# use okapi_operation::*;
# use speka::*;
#[openapi(
parameters(
query(
Expand Down Expand Up @@ -233,7 +233,7 @@ async fn handler() {}
Unlike header and query parameters, all path parameters is mandatory.

```no_run
# use okapi_operation::*;
# use speka::*;
#[openapi(
parameters(
path(
Expand Down Expand Up @@ -261,7 +261,7 @@ async fn handler() {}
* schema (path, mandatory) - path to type of parameter.

```no_run
# use okapi_operation::*;
# use speka::*;
#[openapi(
parameters(
cookie(
Expand All @@ -281,7 +281,7 @@ async fn handler() {}
#### Reference

```no_run
# use okapi_operation::*;
# use speka::*;
#[openapi(
parameters(
reference = "#/components/parameters/ReusableHeader"
Expand All @@ -295,7 +295,7 @@ async fn handler() {}
Specifying multiple parameters is supported:

```no_run
# use okapi_operation::*;
# use speka::*;
#[openapi(
parameters(
header(
Expand Down Expand Up @@ -338,7 +338,7 @@ Request body definition have following attributes:
* content (path, optional) - path to type, which schema should be used. If not speified, argument's type is used.

```no_run
# use okapi_operation::*;
# use speka::*;
# use okapi::schemars::*;
# struct Json<T>(T);
# impl_to_media_types_for_wrapper!(Json<T>, "application/json");
Expand Down Expand Up @@ -384,7 +384,7 @@ Responses can be:
Return type should implement [`ToResponses`] trait.

```no_run
# use okapi_operation::*;
# use speka::*;
# use okapi::schemars::*;
# struct Json<T>(T);
# impl_to_media_types_for_wrapper!(Json<T>, "application/json");
Expand All @@ -405,7 +405,7 @@ async fn handler() -> Json<Response> {
If return type doesn't implement [`ToResponses`], it can be ignored with special attribute `ignore_return_type`:

```no_run
# use okapi_operation::*;
# use speka::*;
#[openapi(
responses(
ignore_return_type = true,
Expand Down Expand Up @@ -433,7 +433,7 @@ Single response have following attributes:
* headers (list, optional) - list of headers (definition is the same as in request parameters). References to header is also allowed.

```no_run
# use okapi_operation::*;
# use speka::*;
# use okapi::schemars::*;
# struct Json<T>(T);
# impl_to_media_types_for_wrapper!(Json<T>, "application/json");
Expand Down Expand Up @@ -474,7 +474,7 @@ async fn handler() {
Responses can be generated from type, which implement [`ToResponses`]:

```no_run
# use okapi_operation::*;
# use speka::*;
# use okapi::schemars::*;
# struct Json<T>(T);
# impl_to_media_types_for_wrapper!(Json<T>, "application/json");
Expand Down Expand Up @@ -504,7 +504,7 @@ Reference to response have following attributes:
* reference (string, mandatory).

```no_run
# use okapi_operation::*;
# use speka::*;
#[openapi(
responses(
reference(
Expand All @@ -530,7 +530,7 @@ first occurence is used. Responses merged in following order:
* from types.

```no_run
# use okapi_operation::*;
# use speka::*;
# use okapi::schemars::*;
# struct Json<T>(T);
# impl_to_media_types_for_wrapper!(Json<T>, "application/json");
Expand Down Expand Up @@ -572,7 +572,7 @@ Security scheme have following attributes:
If multiple schemes specified, they are combined as OR. AND is not currently supported.

```no_run
# use okapi_operation::*;
# use speka::*;
#[openapi(
security(
security_scheme(
Expand All @@ -592,7 +592,7 @@ async fn handler() {}
For convenience this crate provide builder-like [`OpenApiBuilder`] type for creating OpenAPI specification:

```rust
# use okapi_operation::*;
# use speka::*;
# use okapi::schemars::*;
# use http::Method;
# struct Json<T>(T);
Expand Down Expand Up @@ -638,6 +638,6 @@ assert!(generate_openapi_specification().is_ok());

* [ ] support examples on MediaType or Parameter (examples supported on types via `JsonSchema` macro)
* [ ] support inferring schemas of parameters from function definitions
* [ ] support for renaming or changing paths to okapi/schemars/okapi-operations in macro
* [ ] support for renaming or changing paths to okapi/schemars/spekas in macro
* [ ] more examples
* [ ] ...
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ where
/// # Example
///
/// ```rust
/// # use okapi_operation::{*, axum_integration::*};
/// # use speka::{*, axum_integration::*};
/// #[openapi]
/// async fn handler() {}
///
Expand Down Expand Up @@ -134,7 +134,7 @@ where
/// # Example
///
/// ```rust
/// # use okapi_operation::{*, axum_integration::*};
/// # use speka::{*, axum_integration::*};
/// #[openapi]
/// async fn handler() {}
/// let handler_router = Router::new().route("/", get(openapi_handler!(handler)));
Expand Down Expand Up @@ -184,7 +184,7 @@ where
/// # Example
///
/// ```rust
/// # use okapi_operation::{*, axum_integration::*};
/// # use speka::{*, axum_integration::*};
/// #[openapi]
/// async fn handler() {}
/// let handler_router = Router::new().route("/another_handler", get(openapi_handler!(handler)));
Expand Down Expand Up @@ -368,7 +368,7 @@ where
/// # Example
///
/// ```rust
/// # use okapi_operation::{*, axum_integration::*};
/// # use speka::{*, axum_integration::*};
/// #[openapi]
/// async fn handler() {}
///
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit a18a30f

Please sign in to comment.