[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 Aug 9, 2016
YaoYao-dd:top-enum-error-securityscope-newline-error
Merged
[JAVA][SPRING-MVC]Top enum and securityscope newline cause invalid auto-generated java code during springmvc code generation#3491wing328 merged 2 commits intoswagger-api:2.3.0from YaoYao-dd:top-enum-error-securityscope-newline-error
wing328 merged 2 commits intoswagger-api:2.3.0from
YaoYao-dd:top-enum-error-securityscope-newline-error
Conversation
…e in markdown, generated api will break as an extra newline is added.
…el definition, auto-generated code is invalid.
Contributor
|
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. |
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: |
Contributor
|
OK. No worry. I'll try to reproduce it. |
Contributor
|
I've merged your fix for description into master: 79385aa. For header enum value, I'll perform more tests. |
Contributor
Author
|
thanks. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Host, Base Path, Schemes and Content Types
host:
DEV
testApp.com
basePath:
/test/v2
schemes:
produces:
consumes:
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:
Tags
tags:
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