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 Component to Schema #243

Merged
merged 12 commits into from
Aug 8, 2022

Conversation

kellpossible
Copy link
Contributor

@kellpossible kellpossible commented Aug 6, 2022

As outlined in the discussion #215 (comment)

Public facing breaking changes:

  • Rename Component enum to Schema.
  • Rename Component trait to ToSchema.
  • Rename ComponentType to SchemaType.
  • Rename ComponentFormat to SchemaFormat.
  • Rename #[component(...)] struct/enum/field attributes to #[schema(...)].
  • Rename Property field component_type to schema_type.
  • Rename Object field component_type to schema_type.
  • Rename Array field component_type to schema_type.
  • Rename Ref method from_component_name() to from_schema_name().
  • ComponentBuilder's methods schema() and schema_from_iter() now accept Into<RefOr<Schema>> instead of Into<Schema>, so schema components can either be references or inline definitions. For calls which were passing Into<Schema> implementations like ObjectBuilder (e.g. .schema(ObjectBuilder::new())), now needs to be wrapped in .schema(Schema::from(ObjectBuilder::new())) in order to resolve the type.
  • Change #[openapi(components(...), responses(...)] to #[openapi(components(schemas(...), responses(...))].

Internal changes:

  • Rename ComponentAttr to SchemaAttr.

TODO:

@kellpossible
Copy link
Contributor Author

@juhaku how does this look? It's not completely ready, but before I put the work in to polish it up and fix any broken compilation and tests, wanted to get your feedback.

Copy link
Owner

@juhaku juhaku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow.. this is crude work. Looks pretty good. There was couple of cases where derive_to_schema should have been utoipa::ToSchema.

tests/component_derive_test.rs Outdated Show resolved Hide resolved
Copy link
Owner

@juhaku juhaku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🏆 Super

@kellpossible
Copy link
Contributor Author

@juhaku thanks! Still a couple more TODO items and this will be ready, hopefully in about 30 minutes 🙂

Copy link
Owner

@juhaku juhaku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@juhaku
Copy link
Owner

juhaku commented Aug 7, 2022

Rename in scripts/test.sh component_derive_no_serde_json to the actual name of the test. I suppose it is now schema_derive_no_serde_json same for CI in .github/workflows/build.yaml :)

@kellpossible kellpossible marked this pull request as ready for review August 7, 2022 23:21
@kellpossible
Copy link
Contributor Author

Rename in scripts/test.sh component_derive_no_serde_json to the actual name of the test. I suppose it is now schema_derive_no_serde_json same for CI in .github/workflows/build.yaml :)

Fixed!

Copy link
Owner

@juhaku juhaku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great.. hard work of you 🙂 Many thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants