Skip to content

Schemas are parsed in spinal case instead of camel case when using path references #124

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

Closed
rombru opened this issue Mar 8, 2021 · 6 comments
Labels
bug Something isn't working
Milestone

Comments

@rombru
Copy link

rombru commented Mar 8, 2021

Hello,

When using path reference,

  '/users/{userId}':
    $ref: ./apis/user.v1.yaml#/paths/~1users~1{userId}

The schemas used by the referenced path are parsed in spinal-case,
public class user {

For schemas whose name is in several parts, like UserSearch, the parser writes a hyphen (user-search) and stops because the syntax of java doesn't support that.

Because it's a bit complicated to exlain I've attached the full example
openapi-bug.zip

@hauner
Copy link
Member

hauner commented Mar 9, 2021

@hauner hauner added the bug Something isn't working label Mar 9, 2021
@rombru
Copy link
Author

rombru commented Mar 9, 2021

I've tested different use cases of path references, while looking at your tests.

Here's another example that shows a problem with page composition, and one with global parameters:

  • Instead of ResponseEntity <Page >, the parser write ResponseEntity >
  • Parameters used for multiple paths are not read. An example is in the file user-userId.api.v1.yaml.

openapi-bug-pageable-and-params.zip

I will not use references between the paths for now, that's no big deal.
Hope the example helps you a bit more.

@hauner
Copy link
Member

hauner commented Mar 9, 2021

The examples help a lot, Thanks.

The issue is that the processor tries to get schema names (titles) of $refs by extracting them from the $ref path. That fails for a lot of $refs in your example.

Looking at it now, I don't understand why it works at all ;-)

@hauner
Copy link
Member

hauner commented Mar 11, 2021

Fixed it. Both examples produce proper code now. :-)

That was a nasty one, but my original code wasn't so bad at all. The swagger parser is doing something very similar internally. :-)

Release will follow in the next days.

@rombru
Copy link
Author

rombru commented Mar 11, 2021

Nice ! So quick !

I have no doubts about the quality of the code.
This is one of the reasons that pushes me to use it.

Thank you 😃

hauner added a commit to openapi-processor/openapi-processor-core that referenced this issue Mar 12, 2021
hauner added a commit to openapi-processor/openapi-processor-core that referenced this issue Mar 12, 2021
hauner added a commit to openapi-processor/openapi-processor-core that referenced this issue Mar 12, 2021
hauner added a commit to openapi-processor/openapi-processor-core that referenced this issue Mar 12, 2021
@hauner hauner added this to the 2021.3 milestone Mar 14, 2021
@hauner
Copy link
Member

hauner commented Mar 14, 2021

published 2021.3, fixing this one.

@hauner hauner closed this as completed Mar 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants