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

Update SharedCodegen to fallback to title usage if x-model is not present #21

Merged
merged 1 commit into from
Mar 17, 2019

Conversation

macisamuele
Copy link
Collaborator

The current plugin does use x-model field for model name determination.

According to the swagger specification title should be used to define the model name.
Internally, in Yelp, we heavily use x-model custom vendor extension to be able to define names also for objects that do not allow the presence of title.

The goal of this PR is to ensure that title is honoured if present and used as fallback in case x-model is not present.

Let's get the following specs

swagger: "2.0",
info: {
  title: Test
  version: 1.0.0
paths: {},
definitions:
  def1:
    type: object
  def2:
    type: object
    x-model: model2
  def3:
    title: title3
    type: object
  def4:
    title: title4
    type: object
    x-model: model4

Before this PR the generated models would be:

  • def1 for #/definitions/def1
  • model2 for #/definitions/def2
  • def3 for #/definitions/def3
  • model4 for #/definitions/def4
    After this PR the generated models would be:
  • def1 for #/definitions/def1
  • model2 for #/definitions/def2
  • title3 for #/definitions/def3 DIFFERENT
  • model4 for #/definitions/def4

@cortinico cortinico merged commit 08a09e3 into Yelp:master Mar 17, 2019
@macisamuele macisamuele deleted the maci-add-title-fallback branch March 18, 2019 10:57
@cortinico cortinico added this to the 1.1.0 milestone Jun 13, 2019
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.

None yet

2 participants