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

Alias to enum does not work #252

Open
meloniasty opened this issue Jun 14, 2019 · 1 comment
Open

Alias to enum does not work #252

meloniasty opened this issue Jun 14, 2019 · 1 comment

Comments

@meloniasty
Copy link

Hi,
I have defined alias for enum in swagger.yml :

  components:
    schemas:
      Colors:
      type: string
      enum: &COLORS
        - black
        - white
        - red
        - green
        - blue

but it does not recognised properly in routes file.
routes:

###
#  summary: Get logged user
#  parameters:
#   - name: category_id
#     in: query
#     type: integer
#     required: false
#   - name: product_type
#     in: query
#     type: string
#     enum: *COLORS
#   - name: date
#     in: query
#     type: string
#     pattern: '^\d{2}-\d{2}-\d{4}$'
#     required: false
#     description: Date in format dd-MM-yyyy
#  responses:
#    200:
#       description: json with provision table definitions
###
GET        /users        controllers.HomeController.index

I'm getting exception when use sbt command swagger or run:

[play-swagger-alias] $ run
[info] Running com.iheart.playSwagger.SwaggerSpecRunner /media/dawid/DATA/praca/it.impossible/play-swagger-alias/target/swagger/swagger.json routes models  false 1.0-SNAPSHOT false
[error] (run-main-0) found undefined alias COLORS
[error]  in 'string', line 11, column 10:
[error]        enum: *COLORS
[error]              ^
[error] found undefined alias COLORS
[error]  in 'string', line 11, column 10:
[error]        enum: *COLORS
[error]              ^
[error] 
[error] 	at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:137)
[error] 	at org.yaml.snakeyaml.composer.Composer.composeValueNode(Composer.java:246)
[error] 	at org.yaml.snakeyaml.composer.Composer.composeMappingChildren(Composer.java:237)
[error] 	at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:225)
[error] 	at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:154)
[error] 	at org.yaml.snakeyaml.composer.Composer.composeSequenceNode(Composer.java:199)
[error] 	at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:152)
[error] 	at org.yaml.snakeyaml.composer.Composer.composeValueNode(Composer.java:246)
[error] 	at org.yaml.snakeyaml.composer.Composer.composeMappingChildren(Composer.java:237)
[error] 	at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:225)
[error] 	at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:154)
[error] 	at org.yaml.snakeyaml.composer.Composer.composeDocument(Composer.java:122)
[error] 	at org.yaml.snakeyaml.composer.Composer.getSingleNode(Composer.java:105)
[error] 	at org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseConstructor.java:122)
[error] 	at org.yaml.snakeyaml.Yaml.loadFromReader(Yaml.java:505)
[error] 	at org.yaml.snakeyaml.Yaml.load(Yaml.java:424)
[error] 	at com.iheart.playSwagger.SwaggerSpecGenerator.parseYaml(SwaggerSpecGenerator.scala:301)
[error] 	at com.iheart.playSwagger.SwaggerSpecGenerator.$anonfun$endPointSpec$1(SwaggerSpecGenerator.scala:352)
[error] 	at scala.Option.map(Option.scala:163)
[error] 	at com.iheart.playSwagger.SwaggerSpecGenerator.tryParseYaml$1(SwaggerSpecGenerator.scala:352)
[error] 	at com.iheart.playSwagger.SwaggerSpecGenerator.$anonfun$endPointSpec$15(SwaggerSpecGenerator.scala:404)
[error] 	at scala.Option.orElse(Option.scala:306)

seems that generator does not know alias

I pushed example project with bug here: https://github.com/meloniasty/play-swagger-alias

@Javakky-pxv
Copy link
Collaborator

@meloniasty
We are currently reviewing it. It may take some time, but we plan to address it.

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

No branches or pull requests

2 participants