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

chore: infer name for object schema #65

Merged
merged 20 commits into from
Feb 22, 2021

Conversation

magicmatatjahu
Copy link
Member

@magicmatatjahu magicmatatjahu commented Feb 17, 2021

Description

  • reflect names of declarations, definitions, properties by propertyName and save them in x-modelgen-inferred-name, then infer this name to $id CommonModel's property
  • update tests

Related issue(s)
See also asyncapi/shape-up-process#45

@magicmatatjahu magicmatatjahu marked this pull request as ready for review February 17, 2021 17:03
Copy link
Member

@jonaslagoni jonaslagoni left a comment

Choose a reason for hiding this comment

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

Most of the things looks good I however got a few things that needs to be addressed first:

  • Does it really make sense to call it originalSchema anymore? since it is no longer the original but a modified version?
  • Does it make sense to have $id as part of the CommonModel anymore since your new name kinda replaces this right? This also means you can remove the anonymous schema id naming functionality.
  • Skipped tests need to be unskipped
  • I would love to see unit tests for this function instead of relying on integration tests to show it.

src/simplification/Simplifier.ts Outdated Show resolved Hide resolved
test/blackbox/AsyncAPI.spec.ts Show resolved Hide resolved
test/processors/AsyncAPIInputProcessor.spec.ts Outdated Show resolved Hide resolved
@magicmatatjahu
Copy link
Member Author

magicmatatjahu commented Feb 18, 2021

@jonaslagoni Thanks for review!

Does it really make sense to call it originalSchema anymore? since it is no longer the original but a modified version?

I know, but we have an architectural problem. As you know we have this problem with additional iteration in toSchema function, and I don't know why. If I add name extension after toSchema, then I had a problem naming, because in one test as I remember in extension I had a test name and should be street_name etc, so I cannot add naming after writing schema to originalSchema.

Also extension shouldn't be treated as changing schema -> this same we make inside our parser-js.

@magicmatatjahu
Copy link
Member Author

@jonaslagoni I removed name and save name to $id and also added missing test for new function.

Copy link
Member

@jonaslagoni jonaslagoni left a comment

Choose a reason for hiding this comment

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

So my requirement for this infer name is that name is unique for all schemas, this might be wrong, but then I dont see how we can use this in replacement of the anon schema naming?

test/processors/JsonSchemaInputProcessor.spec.ts Outdated Show resolved Hide resolved
Copy link
Member

@jonaslagoni jonaslagoni left a comment

Choose a reason for hiding this comment

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

Just have two comments, looking great overall!

src/processors/JsonSchemaInputProcessor.ts Outdated Show resolved Hide resolved
src/processors/JsonSchemaInputProcessor.ts Outdated Show resolved Hide resolved
docs/customization.md Outdated Show resolved Hide resolved
Copy link
Member

@jonaslagoni jonaslagoni left a comment

Choose a reason for hiding this comment

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

🥳

@magicmatatjahu magicmatatjahu merged commit 94b2b1e into asyncapi:master Feb 22, 2021
@magicmatatjahu magicmatatjahu deleted the schema-naming branch February 22, 2021 20:18
@asyncapi-bot
Copy link
Contributor

🎉 This PR is included in version 0.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

3 participants