Skip to content

[JAVA][SPRING-MVC]Top enum and securityscope newline cause invalid auto-generated java code during springmvc code generation#3491

Merged
wing328 merged 2 commits intoswagger-api:2.3.0from
YaoYao-dd:top-enum-error-securityscope-newline-error
Aug 9, 2016
Merged

[JAVA][SPRING-MVC]Top enum and securityscope newline cause invalid auto-generated java code during springmvc code generation#3491
wing328 merged 2 commits intoswagger-api:2.3.0from
YaoYao-dd:top-enum-error-securityscope-newline-error

Conversation

@YaoYao-dd
Copy link
Contributor

@YaoYao-dd YaoYao-dd commented Aug 1, 2016

Two issues found during spring-mvc code generation:
1,for top enum definition, either enum parameter or enum model definition, auto-generated code is invalid.
2,when security.scope. description has a precedent '|' ,newline in markdown, generated api will break as an extra newline is added between "description".

a sample yaml file attached.
1.user-enum&user-type enum type will generate invalid classes.
2.below | will add a unexpected newline between "string", make java code invalid.
AppIdTrust: |
Validate authenticity.

Copyright

swagger: '2.0'

API Information

info:
version: "2.0.0"
title: test API
description: |
The descripton

## HTTP Response Codes
All operations in this service conform to the following response code
structure.  Refer to the table below for a brief description of each.

HTTP Response Code | Description
-------------------|---------
200                | The request has been fulfilled successfully
503                | The server is currently unable to handle the request due to a temporary overloading or maintenance of the server

Host, Base Path, Schemes and Content Types

host:

DEV

testApp.com
basePath:
/test/v2
schemes:

  • https
    produces:
  • application/json
    consumes:
  • application/json

Security

securityDefinitions:
oauth:
type: oauth2
flow: implicit
authorizationUrl: https://oauthr/?username=srvAPxxxxxxENV&password=xxxxxxx&client_id=CLIENT-ID&client_secret=CLIENT-SECRET&grant_type=password
scopes:
AppIdTrust: |
Validate authenticity.
Bearer:
name: Authorization
in: header
type: apiKey
security:

  • oauth:
    • AppIdTrust
  • Bearer: []

Tags

tags:

  • name: testAction

Parameters

parameters:
user-id:
name: user-id
in: header
description: Customer id
type: string
required: false
user-type:
name: user-type
in: header
description: Customer type
type: string
required: true
enum:
- RETAIL
- WHOLESALE
- UNKNOWN

Paths

paths:
/plan:
parameters:
# Mandatory
- $ref: '#/parameters/user-type'
get:
security:
- oauth:
- AppIdTrust
- Bearer: []
tags:
- testAction
description: |
The test description
responses:
200:
description: Plan data
schema:
$ref: '#/definitions/GeneralResponse'
503:
description: The server is currently unable to handle the request due to a temporary overloading or maintenance of the server

Definitions

definitions:
#----------------------------------------------------------------------------

Base Types

#----------------------------------------------------------------------------

GeneralResponse:
type: object
description: |
Generic object
required:
- code
- value
properties:
code:
type: string
value:
type: string

user-enum:
description: Customized enum type
type: string
enum:
- RETAIL
- WHOLESALE
- UNKNOWN

…e in markdown, generated api will break as an extra newline is added.
…el definition, auto-generated code is invalid.
@YaoYao-dd YaoYao-dd changed the title Top enum error securityscope newline error Top enum error and securityscope newline error during springmvc code generation Aug 1, 2016
@YaoYao-dd YaoYao-dd changed the title Top enum error and securityscope newline error during springmvc code generation [JAVA][SPRING-MVC]Top enum error and securityscope newline error during springmvc code generation Aug 1, 2016
@YaoYao-dd YaoYao-dd changed the title [JAVA][SPRING-MVC]Top enum error and securityscope newline error during springmvc code generation [JAVA][SPRING-MVC]Top enum and securityscope newline cause invalid auto-generated java code during springmvc code generation Aug 2, 2016
@wing328
Copy link
Contributor

wing328 commented Aug 3, 2016

For 1, it should be fixed by #3511. Please pull the latest master to give it a try.

For 2, it would be helpful if you can share the spec via gist.github.com so that we can more easily reproduce the issue and confirm this fix.

@wing328 wing328 added this to the v2.2.1 milestone Aug 3, 2016
@wing328 wing328 modified the milestones: v2.2.1, v2.3.0 Aug 8, 2016
@YaoYao-dd
Copy link
Contributor Author

thanks, but gist is not available for me, the issue occurs when there is pipe at the beginning of the description of SecurityDefinition/scope, like below

scopes:
AppIdTrust: |
Validate authenticity.

@wing328
Copy link
Contributor

wing328 commented Aug 9, 2016

OK. No worry. I'll try to reproduce it.

@wing328
Copy link
Contributor

wing328 commented Aug 9, 2016

I've merged your fix for description into master: 79385aa.

For header enum value, I'll perform more tests.

@YaoYao-dd
Copy link
Contributor Author

thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants