Skip to content

Problem implementing oauth security scheme  #88

@ashishjadon2145

Description

@ashishjadon2145

The problem is with the security definition.

openapi: 3.0.1
    info:
      title: My sample API
      description: |-
        Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor inc
    
        

<a href="example.com">example.com</a>
      version: 1.0.0
    security:
      - /myapp-auth.json: []
    tags:
      - name: name1
        description: description1
      - name: name2
        description: description2
      
    

paths:
      /api/v1/path1:
        post:
          tags:
            - Files
          summary: sample summary
          description: some description...

The documentation of the plugin is very limited and I'm not able to use the correct syntax i guess. This is what i am doing

<plugin>
            <groupId>io.openapitools.swagger</groupId>
            <artifactId>swagger-maven-plugin</artifactId>
            <version>2.1.6</version>
            <configuration>
                <resourcePackages>
                    <resourcePackage>com.example.controller</resourcePackage>
                </resourcePackages>
                <outputDirectory>${basedir}/src/main/resources/</outputDirectory>
                <outputFilename>swagger-file</outputFilename>
                <outputFormats>JSON</outputFormats>
                <prettyPrint>true</prettyPrint>
                <swaggerConfig>
                    <descriptionFile>${basedir}/src/main/resources/description.txt</descriptionFile>
                    <info>
                        <title>myapp API</title>
                        <version>${api.version}</version>
                    </info>
                   <securityRequirements>
                        <securityRequirement>
                            <entries>
                                <entry>
                                    <name>/myApp-auth.json</name>
                                </entry>
                            </entries>
                        </securityRequirement> 
                    </securityRequirements>
                </swaggerConfig>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

below is my myApp.json file

{
  "myApp_auth": {
    "type": "oauth2",
    "tokenUrl": "example.com",
    "flow": "password",
    "scopes": {
      "read.pet": "read scope",
      "write.pet": "modify scope",
      ...

    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions