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

Problem at generation of security scheme #71

Closed
flueders opened this issue Dec 17, 2020 · 4 comments
Closed

Problem at generation of security scheme #71

flueders opened this issue Dec 17, 2020 · 4 comments

Comments

@flueders
Copy link

flueders commented Dec 17, 2020

Describe the bug
I want to add A SecurityRequirement to my Open API docs.

After interpreting https://github.com/openapi-tools/swagger-maven-plugin/blob/master/src/main/java/io/openapitools/swagger/config/SwaggerSecurityRequirement.java , this is what I did:

<components>
	<securitySchemes>
		<authorization>
			<type>apiKey</type>
			<name>Authorization</name>
			<in>header</in>
			<scheme>http</scheme>
		</authorization>
		<area>
			<type>apiKey</type>
			<name>Area</name>
			<in>header</in>
			<scheme>http</scheme>
		</area>
	</securitySchemes>
</components>
<securityRequirements>
	<authorization>
		<entries>
			<name>Authorization</name>
		</entries>
	</authorization>
	<area>
		<entries>
			<name>Area</name>
		</entries>
	</area>
</securityRequirements>

This produces the following error:

[ERROR] Failed to execute goal io.openapitools.swagger:swagger-maven-plugin:2.1.5:generate (default) on project application-webservices:
Unable to parse configuration of mojo io.openapitools.swagger:swagger-maven-plugin:2.1.5:generate for parameter name: 
Cannot find default setter in class io.openapitools.swagger.config.SwaggerSecurityRequirement$Entry -> [Help 1]

However, if I remove the <name> tags from inside the <entries>, the maven-plugin does not throw any error.
But looking at the generated file, this is what was generated:

"security" : [ null, null ]

Expected behavior
The expected result would be :

  "security" : [ {"Authorization": []}, {"Area": []}],

Note: the securitySchemes tag is being created correctly. But to enable the schemes globally, the additional security tag is needed.

So this seems to be a bug while parsing the configuration. Or is there just a mistake in my configuration?

@flueders
Copy link
Author

@langecode Can you or someone else help me here? Thanks in advance!

@langecode
Copy link
Member

langecode commented Dec 22, 2020 via email

@langecode
Copy link
Member

You might take a look at the example in the unittests: https://github.com/openapi-tools/swagger-maven-plugin/blob/master/src/test/resources/generate-mojo-full-pom.xml#L60

This should explain how to add the areas :-)

@flueders
Copy link
Author

Thank you very much! This helped to solve my problem.

Just for the record, this is how it is done:

<securityRequirements>
	<authorization>
		<entries>
			<entry>
				<name>authorization</name>
			</entry>
		</entries>
	</authorization>
</securityRequirements>

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