j-d-carmichael / boats

Beautiful Open Api Template System
MIT License
57 stars 8 forks source link

Attempt to resolve opId issues with windows #30

Closed p-mcgowan closed 3 years ago

p-mcgowan commented 4 years ago

Will need to test this

p-mcgowan commented 4 years ago

@intelman10c if you still use vscode on windows, would it also be possible to test this feature?

I could test on my machine at home but would need a sample repo to reproduce the issue

j-d-carmichael commented 4 years ago

OK - it took a while as windows had a fit downloading the internet for non-requested updates.. but i booted into the windows, and tested this in windows (not the linux sub system) and it works nicely!

p-mcgowan commented 4 years ago

Awesome thanks - were you able to reproduce the original error on the main branch? I'm wondering if it was partly a particular setup (no real faith in the fix...)

j-d-carmichael commented 4 years ago

tbh: i did not :s

will give it another whirl later this evening.. i was happy compiled things ok so left windows asap :)

Acrontum-Carmichael commented 4 years ago

on windows, main branch test on latest version (v2.0.3):

{
    "name": "boatstest",
    "version": "1.0.0",
    "description": "",
    "main": "index.js",
    "scripts": {
        "boats": "boats",
        "build:json": "boats -i ./src/index.yml.njk -o ./build/${npm_package_name}.json",
        "build:yaml": "boats -i ./src/index.yml.njk -o ./build/${npm_package_name}.yml",
        "build": "npm run build:json && npm run build:yaml"
    },
    "author": "",
    "license": "ISC",
    "dependencies": {
        "boats": "^2.0.3"
    }
}

output

swagger: '2.0'
info:
  version: 1.0.1
  title: boatstest
  description: A sample API
  contact:
    name: Swagger API Team
    email: john@boats.io
    url: 'https://github.com/johndcarmichael/boats/'
  license:
    name: Apache 2.0
    url: 'https://www.apache.org/licenses/LICENSE-2.0.html'
schemes:
  - https
host: api.example.com
basePath: /v1
securityDefinitions:
  jwtToken:
    type: apiKey
    in: header
    name: authorization
  apiKey:
    type: apiKey
    in: header
    name: x-api-key
paths:
  /v1/star-wars/:
    get:
      tags:
        - starWars
      summary: get star wars details
      description: get star wars details
      operationId: srcPathsV1StarWarsGet
      responses:
        '200':
          description: Successful fetch
          schema:
            $ref: '#/definitions/StarWars'
        '404':
          description: start not found
  /weather:
    get:
      tags:
        - weather
      summary: weather search
      description: Search for weather objects
      operationId: srcPathsV1WeatherGet
      x-filename: src\paths\v1\weather\get
      parameters:
        - $ref: '#/parameters/QueryOffset'
        - $ref: '#/parameters/QueryTextSearch'
      responses:
        '200':
          description: Successful fetch
          schema:
            properties:
              meta:
                $ref: '#/definitions/GenericSearchMeta'
              data:
                type: array
                items:
                  $ref: '#/definitions/WeatherModel'
        '404':
          description: Temp not found
    post:
      tags:
        - weather
      summary: weather data
      description: Create a new weather record.
      operationId: srcPathsV1WeatherPost
      parameters:
        - in: body
          name: srcPathsV1WeatherPost
          description: Optional description in *Markdown*
          required: true
          schema:
            $ref: '#/definitions/WeatherPost'
      responses:
        '200':
          description: Successful temp creation
          schema:
            $ref: '#/definitions/WeatherModel'
        '422':
          description: Invalid form data provided
      x-permission: boatstestCreateSrcPathsV1WeatherPost
  '/weather/id/{id}':
    get:
      tags:
        - weather
      summary: One weather object
      description: Get the full weather object
      operationId: srcPathsV1WeatherIdGet
      produces:
        - application/json
      parameters:
        - $ref: '#/parameters/PathId'
      responses:
        '200':
          description: Successful fetch
          schema:
            $ref: '#/definitions/WeatherModel'
        '404':
          description: Temp not found
    delete:
      tags:
        - weather
      summary: weather set to rain
      description: Reset awful sunny weather to excellent rainy weather
      operationId: srcPathsV1WeatherIdDelete
      x-filename: src\paths\v1\weather\id\delete
      parameters:
        - $ref: '#/parameters/PathId'
        - $ref: '#/parameters/QueryOffset'
        - $ref: '#/parameters/QueryTextSearch'
        - in: query
          name: areYouSure
          required: true
          type: string
        - in: query
          name: areYouSureSure
          required: true
          type: string
      responses:
        '200':
          description: Deleted
        '404':
          description: Temp not found
    put:
      tags:
        - weather
      summary: weather data
      description: Create a new weather record.
      operationId: srcPathsV1WeatherIdPut
      produces:
        - application/json
      parameters:
        - $ref: '#/parameters/PathId'
        - in: body
          name: srcPathsV1WeatherIdPut
          description: Optional description in *Markdown*
          required: true
          schema:
            $ref: '#/definitions/WeatherIdPut'
      responses:
        '200':
          description: Successful temp creation
          schema:
            $ref: '#/definitions/WeatherModel'
        '422':
          description: Invalid form data provided
  '/weather/id/{id}/pattern':
    get:
      tags:
        - weather
      summary: One weather object
      description: Get the full weather object
      operationId: srcPathsV1WeatherIdPatternGet
      produces:
        - application/json
      parameters:
        - $ref: '#/parameters/PathId'
      responses:
        '200':
          description: Successful fetch
          schema:
            $ref: '#/definitions/WeatherModel'
        '404':
          description: Temp not found
  /weather/latest:
    get:
      tags:
        - weather
      summary: lastest weather data
      description: Get the latest temperatures
      operationId: srcPathsV1WeatherLatestGet
      produces:
        - application/json
      responses:
        '200':
          description: Successful fetch
          schema:
            $ref: '#/definitions/WeatherModels'
        '404':
          description: Temp not found
parameters:
  HeaderSearchId:
    in: header
    name: Search-Id
    type: string
    description: 'Unique search {id}'
    x-example: 569eecd9-9962-4aed-a0f0-30476c6a82ed
  PathId:
    in: path
    name: id
    type: integer
    required: true
    description: Numeric ID of object to fetch
  QueryOffset:
    in: query
    name: offset
    required: false
    type: integer
    description: The number of items to skip before starting to collect the result set.
  QueryTextSearch:
    in: query
    name: textSearch
    required: false
    type: string
    description: Search string to query
definitions:
  GenericSearchMeta:
    properties:
      totalResultCount:
        type: number
      offset:
        type: number
      limit:
        type: number
  LocationPatch:
    type: object
    properties:
      name:
        type: string
      coordinates:
        type: array
        items:
          type: string
  LocationPost:
    type: object
    required:
      - name
      - coordinates
    properties:
      name:
        type: string
      coordinates:
        type: array
        items:
          type: string
  StarWars:
    type: object
    properties:
      empireName:
        type: string
      rebellious:
        type: boolean
      darthVader:
        type: boolean
  WeatherIdPut:
    allOf:
      - $ref: '#/definitions/WeatherPost'
      - type: object
        properties:
          id:
            type: integer
  WeatherModel:
    type: object
    properties:
      id:
        type: integer
      date:
        type: string
        format: date
      location:
        type: string
      cloudCoverPercentage:
        type: integer
      humidityPercentage:
        type: integer
      temperature:
        type: number
  WeatherModels:
    type: array
    items:
      $ref: '#/definitions/WeatherModel'
  WeatherPost:
    type: object
    properties:
      date:
        type: string
        format: date
      location:
        type: string
      cloudCoverPercentage:
        type: integer
      humidityPercentage:
        type: integer
      temperature:
        type: number

On thing was off though:

        "build:yaml": "boats -i ./src/index.yml.njk -o ./build/${npm_package_name}.yml",

This npm trick doesn't work on windows 10 with the latest node lts v14.

The name output is: build/${npm_package_name}.yml

Other than that though, nothing appears to be broken.

It could be that node 14 maybe automatically resolves path resolutions ? either-way, this pr is good to go in my opinion,

p-mcgowan commented 4 years ago

yeah it's a shell env variable expansion, so I'm not terribly surprised it doesn't work. If we really wanted to add support we could use something like cross-env

Acrontum-Carmichael commented 4 years ago

yea but this is only a cosmetic thing - if they want to change this it is trivial.. not worth bringing in a whole other package?

p-mcgowan commented 3 years ago

yep - 100% agree