Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename gen module to generate #174

Merged
merged 1 commit into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/aide-axum-typed-multipart/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use std::ops::Deref;

use aide::{
gen::GenContext,
generate::GenContext,
openapi::{MediaType, Operation, RequestBody, SchemaObject},
operation::set_body,
OperationInput,
Expand Down
6 changes: 3 additions & 3 deletions crates/aide-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ pub fn derive_operation_io(ts: TokenStream) -> TokenStream {
ts.extend(quote! {
impl #i_gen aide::OperationInput for #name #t_gen #w_gen {
fn operation_input(
ctx: &mut aide::gen::GenContext,
ctx: &mut aide::generate::GenContext,
operation: &mut aide::openapi::Operation
) {
<#input as aide::OperationInput>::operation_input(
Expand All @@ -142,7 +142,7 @@ pub fn derive_operation_io(ts: TokenStream) -> TokenStream {
impl #i_gen aide::OperationOutput for #name #t_gen #w_gen {
type Inner = <#output as aide::OperationOutput>::Inner;
fn operation_response(
ctx: &mut aide::gen::GenContext,
ctx: &mut aide::generate::GenContext,
operation: &mut aide::openapi::Operation
) -> Option<aide::openapi::Response> {
<#output as aide::OperationOutput>::operation_response(
Expand All @@ -151,7 +151,7 @@ pub fn derive_operation_io(ts: TokenStream) -> TokenStream {
)
}
fn inferred_responses(
ctx: &mut aide::gen::GenContext,
ctx: &mut aide::generate::GenContext,
operation: &mut aide::openapi::Operation
) -> Vec<(Option<u16>, aide::openapi::Response)> {
<#output as aide::OperationOutput>::inferred_responses(
Expand Down
7 changes: 7 additions & 0 deletions crates/aide/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## Unreleased

- **breaking:** Rename `gen` module to `generate`,
because `gen` is going to be a keyword in Rust 2024 ([#174])

[#174]: https://github.com/tamasfe/aide/pull/174

## 0.13.5

- **added:** Implement `OperationHandler` for `axum::handler::Layered` ([#133])
Expand Down
26 changes: 13 additions & 13 deletions crates/aide/src/axum/inputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl<T> OperationInput for axum_extra::typed_header::TypedHeader<T>
where
T: axum_extra::headers::Header,
{
fn operation_input(ctx: &mut crate::gen::GenContext, operation: &mut Operation) {
fn operation_input(ctx: &mut crate::generate::GenContext, operation: &mut Operation) {
let s = ctx.schema.subschema_for::<String>();
add_parameters(
ctx,
Expand Down Expand Up @@ -72,7 +72,7 @@ where

#[cfg(any(feature = "axum-json", feature = "axum-extra-json-deserializer"))]
fn operation_input_json<T: JsonSchema>(
ctx: &mut crate::gen::GenContext,
ctx: &mut crate::generate::GenContext,
operation: &mut Operation,
) {
let schema = ctx.schema.subschema_for::<T>().into_object();
Expand Down Expand Up @@ -108,7 +108,7 @@ impl<T> OperationInput for axum::Json<T>
where
T: JsonSchema,
{
fn operation_input(ctx: &mut crate::gen::GenContext, operation: &mut Operation) {
fn operation_input(ctx: &mut crate::generate::GenContext, operation: &mut Operation) {
operation_input_json::<T>(ctx, operation);
}
}
Expand All @@ -118,7 +118,7 @@ impl<T> OperationInput for axum_extra::extract::JsonDeserializer<T>
where
T: JsonSchema,
{
fn operation_input(ctx: &mut crate::gen::GenContext, operation: &mut Operation) {
fn operation_input(ctx: &mut crate::generate::GenContext, operation: &mut Operation) {
operation_input_json::<T>(ctx, operation);
}
}
Expand All @@ -128,7 +128,7 @@ impl<T> OperationInput for axum::extract::Form<T>
where
T: JsonSchema,
{
fn operation_input(ctx: &mut crate::gen::GenContext, operation: &mut Operation) {
fn operation_input(ctx: &mut crate::generate::GenContext, operation: &mut Operation) {
let schema = ctx.schema.subschema_for::<T>().into_object();
let resolved_schema = ctx.resolve_schema(&schema);

Expand Down Expand Up @@ -162,7 +162,7 @@ impl<T> OperationInput for Path<T>
where
T: JsonSchema,
{
fn operation_input(ctx: &mut crate::gen::GenContext, operation: &mut Operation) {
fn operation_input(ctx: &mut crate::generate::GenContext, operation: &mut Operation) {
let schema = ctx.schema.subschema_for::<T>().into_object();
let params = parameters_from_schema(ctx, schema, ParamLocation::Path);
add_parameters(ctx, operation, params);
Expand All @@ -174,7 +174,7 @@ impl<T> OperationInput for axum::extract::Query<T>
where
T: JsonSchema,
{
fn operation_input(ctx: &mut crate::gen::GenContext, operation: &mut Operation) {
fn operation_input(ctx: &mut crate::generate::GenContext, operation: &mut Operation) {
let schema = ctx.schema.subschema_for::<T>().into_object();
let params = parameters_from_schema(ctx, schema, ParamLocation::Query);
add_parameters(ctx, operation, params);
Expand All @@ -184,7 +184,7 @@ where
#[cfg(feature = "axum-ws")]
impl OperationInput for axum::extract::ws::WebSocketUpgrade {
fn operation_input(
ctx: &mut crate::gen::GenContext,
ctx: &mut crate::generate::GenContext,
operation: &mut crate::openapi::Operation,
) {
if operation.responses.is_none() {
Expand Down Expand Up @@ -311,7 +311,7 @@ impl OperationInput for axum::extract::ws::WebSocketUpgrade {

#[cfg(feature = "axum-multipart")]
impl OperationInput for axum::extract::Multipart {
fn operation_input(ctx: &mut crate::gen::GenContext, operation: &mut Operation) {
fn operation_input(ctx: &mut crate::generate::GenContext, operation: &mut Operation) {
set_body(
ctx,
operation,
Expand Down Expand Up @@ -353,7 +353,7 @@ mod extra {
T: OperationInput,
{
fn operation_input(
ctx: &mut crate::gen::GenContext,
ctx: &mut crate::generate::GenContext,
operation: &mut crate::openapi::Operation,
) {
T::operation_input(ctx, operation);
Expand All @@ -365,7 +365,7 @@ mod extra {
T: OperationInput,
{
fn operation_input(
ctx: &mut crate::gen::GenContext,
ctx: &mut crate::generate::GenContext,
operation: &mut crate::openapi::Operation,
) {
T::operation_input(ctx, operation);
Expand All @@ -383,7 +383,7 @@ mod extra {
where
T: JsonSchema,
{
fn operation_input(ctx: &mut crate::gen::GenContext, operation: &mut Operation) {
fn operation_input(ctx: &mut crate::generate::GenContext, operation: &mut Operation) {
let schema = ctx.schema.subschema_for::<T>().into_object();
let resolved_schema = ctx.resolve_schema(&schema);

Expand Down Expand Up @@ -417,7 +417,7 @@ mod extra {
where
T: JsonSchema,
{
fn operation_input(ctx: &mut crate::gen::GenContext, operation: &mut Operation) {
fn operation_input(ctx: &mut crate::generate::GenContext, operation: &mut Operation) {
let schema = ctx.schema.subschema_for::<T>().into_object();
let params = parameters_from_schema(ctx, schema, ParamLocation::Query);
add_parameters(ctx, operation, params);
Expand Down
4 changes: 2 additions & 2 deletions crates/aide/src/axum/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
use std::{convert::Infallible, future::Future, mem, pin::Pin};

use crate::{
gen::{self, in_context},
generate::{self, in_context},
openapi::{OpenApi, PathItem, ReferenceOr, SchemaObject},
operation::OperationHandler,
util::merge_paths,
Expand Down Expand Up @@ -466,7 +466,7 @@ where
});

if needs_reset {
gen::reset_context();
generate::reset_context();
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions crates/aide/src/axum/outputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use schemars::schema::{InstanceType, SingleOrVec};
#[cfg(any(feature = "axum-form", feature = "axum-json"))]
use schemars::JsonSchema;

use crate::{gen::GenContext, operation::OperationOutput};
use crate::{generate::GenContext, operation::OperationOutput};

#[cfg(feature = "axum-json")]
impl<T> OperationOutput for axum::Json<T>
Expand Down Expand Up @@ -41,7 +41,7 @@ where
}

fn inferred_responses(
ctx: &mut crate::gen::GenContext,
ctx: &mut crate::generate::GenContext,
operation: &mut Operation,
) -> Vec<(Option<u16>, Response)> {
if let Some(res) = Self::operation_response(ctx, operation) {
Expand Down Expand Up @@ -90,7 +90,7 @@ where
}

fn inferred_responses(
ctx: &mut crate::gen::GenContext,
ctx: &mut crate::generate::GenContext,
operation: &mut Operation,
) -> Vec<(Option<u16>, Response)> {
if let Some(res) = Self::operation_response(ctx, operation) {
Expand Down Expand Up @@ -139,7 +139,7 @@ impl<T> OperationOutput for Html<T> {
}

fn inferred_responses(
ctx: &mut crate::gen::GenContext,
ctx: &mut crate::generate::GenContext,
operation: &mut Operation,
) -> Vec<(Option<u16>, Response)> {
if let Some(res) = Self::operation_response(ctx, operation) {
Expand All @@ -159,7 +159,7 @@ impl OperationOutput for JsonRejection {
}

fn inferred_responses(
ctx: &mut crate::gen::GenContext,
ctx: &mut crate::generate::GenContext,
operation: &mut Operation,
) -> Vec<(Option<u16>, Response)> {
if let Some(res) = Self::operation_response(ctx, operation) {
Expand All @@ -184,7 +184,7 @@ impl OperationOutput for FormRejection {
}

fn inferred_responses(
ctx: &mut crate::gen::GenContext,
ctx: &mut crate::generate::GenContext,
operation: &mut Operation,
) -> Vec<(Option<u16>, Response)> {
if let Some(res) = Self::operation_response(ctx, operation) {
Expand Down
4 changes: 2 additions & 2 deletions crates/aide/src/axum/routing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use std::{convert::Infallible, mem};

use crate::{
gen::GenContext,
generate::GenContext,
openapi::{Operation, PathItem, ReferenceOr, Response, StatusCode},
Error,
};
Expand All @@ -20,7 +20,7 @@ use tower_layer::Layer;
use tower_service::Service;

use crate::{
gen::in_context,
generate::in_context,
operation::{OperationHandler, OperationInput, OperationOutput},
transform::TransformOperation,
};
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion crates/aide/src/helpers/use_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{

use serde::{Deserialize, Serialize};

use crate::gen::GenContext;
use crate::generate::GenContext;
use crate::openapi::{Operation, Response};
use crate::{OperationInput, OperationOutput};

Expand Down
2 changes: 1 addition & 1 deletion crates/aide/src/helpers/with_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{

use serde::{Deserialize, Serialize};

use crate::gen::GenContext;
use crate::generate::GenContext;
use crate::openapi::{Operation, Response};
use crate::{OperationInput, OperationOutput};

Expand Down
12 changes: 6 additions & 6 deletions crates/aide/src/impls/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{

impl OperationInput for Bytes {
fn operation_input(
ctx: &mut crate::gen::GenContext,
ctx: &mut crate::generate::GenContext,
operation: &mut crate::openapi::Operation,
) {
set_body(
Expand All @@ -30,7 +30,7 @@ impl OperationInput for Bytes {

impl OperationInput for BytesMut {
fn operation_input(
ctx: &mut crate::gen::GenContext,
ctx: &mut crate::generate::GenContext,
operation: &mut crate::openapi::Operation,
) {
Bytes::operation_input(ctx, operation);
Expand All @@ -41,7 +41,7 @@ impl OperationOutput for Bytes {
type Inner = Self;

fn operation_response(
_ctx: &mut crate::gen::GenContext,
_ctx: &mut crate::generate::GenContext,
_operation: &mut Operation,
) -> Option<crate::openapi::Response> {
Some(Response {
Expand All @@ -55,7 +55,7 @@ impl OperationOutput for Bytes {
}

fn inferred_responses(
ctx: &mut crate::gen::GenContext,
ctx: &mut crate::generate::GenContext,
operation: &mut Operation,
) -> Vec<(Option<u16>, Response)> {
if let Some(res) = Self::operation_response(ctx, operation) {
Expand All @@ -70,14 +70,14 @@ impl OperationOutput for BytesMut {
type Inner = Self;

fn operation_response(
ctx: &mut crate::gen::GenContext,
ctx: &mut crate::generate::GenContext,
operation: &mut Operation,
) -> Option<crate::openapi::Response> {
Bytes::operation_response(ctx, operation)
}

fn inferred_responses(
ctx: &mut crate::gen::GenContext,
ctx: &mut crate::generate::GenContext,
operation: &mut Operation,
) -> Vec<(Option<u16>, Response)> {
Bytes::inferred_responses(ctx, operation)
Expand Down
Loading
Loading