Skip to content

Unable parse definition file in windows with read function #1517

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

Open
hemikak opened this issue Jan 18, 2021 · 1 comment
Open

Unable parse definition file in windows with read function #1517

hemikak opened this issue Jan 18, 2021 · 1 comment

Comments

@hemikak
Copy link

hemikak commented Jan 18, 2021

I am trying to parse an OpenAPI definition on a windows machine. The parsed OpenAPI is missing the requestBody which refers to a custom schema called User in this case. I have included the yaml file and also the parse output from debugging.

Following is the java code. I am using implementation "io.swagger.parser.v3:swagger-parser:2.0.24" dependency to parse.

String definitionPath = "G:\\openapi\\src\\test\\resources\\requestBody.yaml"
OpenAPI api = new OpenAPIV3Parser().read(definitionPath);

I found that parsing fails midway at:

Following is the content of the requestBody.yaml file:

openapi: 3.0.0
info:
  title: refComponent
  description: refComponent
  version: 1.0.0
servers:
  - url: 'https'
paths:
  /requestBody:
    post:
      summary: Creates a new user.
      responses:
        200:
          description: OK
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/User'
components:
  schemas:
    User:
      type: object
      required:
        - userName
      properties:
        userName:
          type: string
        firstName:
          type: string
        lastName:
          type: string

The output of the parsing:

class OpenAPI {
    openapi: 3.0.1
    info: class Info {
        title: refComponent
        description: refComponent
        termsOfService: null
        contact: null
        license: null
        version: 1.0.0
    }
    externalDocs: null
    servers: [class Server {
        url: /
        description: null
        variables: null
    }]
    security: null
    tags: null
    paths: class Paths {
        {/requestBody=class PathItem {
            summary: null
            description: null
            get: null
            put: null
            post: class Operation {
                tags: null
                summary: Creates a new user.
                description: null
                externalDocs: null
                operationId: null
                parameters: null
                requestBody: null
                responses: class ApiResponses {
                    {200=class ApiResponse {
                        description: OK
                        headers: null
                        content: class Content {
                            {}
                        }
                        links: null
                        extensions: {}
                        $ref: null
                    }}
                    extensions: null
                }
                callbacks: null
                deprecated: null
                security: null
                servers: null
            }
            delete: null
            options: null
            head: null
            patch: null
            trace: null
            servers: null
            parameters: null
            $ref: null
        }}
    }
    components: class Components {
        schemas: null
        responses: null
        parameters: null
        examples: null
        requestBodies: null
        headers: null
        securitySchemes: null
        links: null
        callbacks: null
    }
}
@jhannes
Copy link
Contributor

jhannes commented May 20, 2021

Is this the same as #1553 ?

Notice that the server url "https" is probably not what you want. A more common situation would be something like /api (relative) or https://api.example.com (absolute)

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