wordnik 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile.lock +1 -1
- data/api_docs/word.json +1 -1
- data/lib/wordnik/operation.rb +18 -12
- data/lib/wordnik/operation_parameter.rb +1 -1
- data/lib/wordnik/resource.rb +2 -21
- data/lib/wordnik/version.rb +1 -1
- data/spec/request_spec.rb +2 -0
- metadata +1 -1
data/Gemfile.lock
CHANGED
data/api_docs/word.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"endPoints":[{"path":"/word.{format}/{word}","description":"","operations":[{"parameters":[{"name":"word","description":"String value of WordObject to return","required":true,"paramType":"path"},{"name":"useCanonical","description":"If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested.","required":false,"paramType":"query"},{"name":"includeSuggestions","description":"Return suggestions (for correct spelling, case variants, etc.)","required":false,"paramType":"query"},{"name":"format","defaultValue":"json","description":"API response format","required":true,"allowableValues":"json,xml","paramType":"path"}],"response":[{"valueType":"wordObject","errorResponses":[{"reason":"Invalid word supplied.","code":400}],"condition":"any"}],"summary":"Given a word as a string, returns the WordObject that represents it","open":false,"httpMethod":"GET"}]},{"path":"/word.{format}/{word}/examples","description":"","operations":[{"parameters":[{"name":"word","description":"Word to return examples for","required":true,"paramType":"path"},{"name":"limit","description":"Maximum number of results to return","required":false,"paramType":"query"},{"name":"includeDuplicates","description":"Show duplicate examples from different sources","required":false,"paramType":"query"},{"name":"contentProvider","description":"Return results from a specific ContentProvider","required":false,"paramType":"query"},{"name":"useCanonical","description":"If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested.","required":false,"paramType":"query"},{"name":"skip","description":"Results to skip","required":false,"paramType":"query"},{"name":"limit","description":"Maximum number of results to return","required":false,"paramType":"query"},{"name":"format","defaultValue":"json","description":"API response format","required":true,"allowableValues":"json,xml","paramType":"path"}],"response":[{"valueType":"exampleSearchResults","errorResponses":[{"reason":"Invalid word supplied.","code":400}],"condition":"any"}],"summary":"Returns examples for a word","open":false,"httpMethod":"GET"}]},{"path":"/word.{format}/{word}/definitions","description":"","operations":[{"parameters":[{"name":"word","description":"Word to return definitions for","required":true,"paramType":"path"},{"name":"limit","description":"Maximum number of results to return","required":false,"paramType":"query"},{"name":"partOfSpeech","description":"CSV list of part-of-speech types","required":false,"allowableValues":"synonym,antonym,variant,equivalent,cross-reference,related-word,rhyme,form,etymologically-related-term,hypernym,hyponym,inflected-form,primary,same-context,verb-form,verb-stem,unknown","paramType":"query"},{"name":"includeRelated","description":"Return related words with definitions","required":false,"paramType":"query"},{"name":"sourceDictionaries","description":"Gets from dictionaries in the supplied order of precedence","required":false,"allowableValues":"ahd, century, wiktionary, webster, wordnet","paramType":"query"},{"name":"useCanonical","description":"If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested.","required":false,"paramType":"query"},{"name":"includeTags","description":"Return a closed set of XML tags in response","required":false,"paramType":"query"},{"name":"format","defaultValue":"json","description":"API response format","required":true,"allowableValues":"json,xml","paramType":"path"}],"response":[{"valueType":"List[definition]","errorResponses":[{"reason":"Invalid word supplied.","code":400},{"reason":"No definitions found.","code":404}],"condition":"any"}],"summary":"Return definitions for a word","open":false,"httpMethod":"GET"}]},{"path":"/word.{format}/{word}/frequency","description":"","operations":[{"parameters":[{"name":"word","description":"Word to return","required":true,"paramType":"path"},{"name":"useCanonical","description":"If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested.","required":false,"paramType":"query"},{"name":"startYear","description":"Starting Year","required":false,"paramType":"query"},{"name":"endYear","description":"Ending Year","required":false,"paramType":"query"},{"name":"format","defaultValue":"json","description":"API response format","required":true,"allowableValues":"json,xml","paramType":"path"}],"response":[{"valueType":"frequencySummary","errorResponses":[{"reason":"Invalid word supplied.","code":400},{"reason":"No results.","code":404}],"condition":"any"},{"valueType":"frequencySummaryE","errorResponses":[{"reason":"Invalid word supplied.","code":400},{"reason":"No results.","code":404}],"condition":"errorBars=true"}],"summary":"Returns word usage over time","open":false,"httpMethod":"GET"}]},{"path":"/word.{format}/{word}/topExample","description":"","operations":[{"parameters":[{"name":"word","description":"Word to fetch examples for","required":true,"paramType":"path"},{"name":"contentProvider","description":"Return results from a specific ContentProvider","required":false,"paramType":"query"},{"name":"useCanonical","description":"If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested.","required":false,"paramType":"query"},{"name":"format","defaultValue":"json","description":"API response format","required":true,"allowableValues":"json,xml","paramType":"path"}],"response":[{"valueType":"example","errorResponses":[{"reason":"Invalid word supplied.","code":400}],"condition":"any"}],"summary":"Returns a top example for a word","open":false,"httpMethod":"GET"}]},{"path":"/word.{format}/{word}/related","description":"","operations":[{"parameters":[{"name":"word","description":"Word for which to return related words","required":true,"paramType":"path"},{"name":"partOfSpeech","description":"CSV list of part-of-speech types","required":false,"paramType":"query"},{"name":"sourceDictionary","description":"Get data from a single dictionary. Valid options are ahd, century, wiktionary, webster, and wordnet.","required":false,"paramType":"query"},{"name":"limit","description":"Maximum number of results to return","required":false,"paramType":"query"},{"name":"useCanonical","description":"If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested.","required":false,"paramType":"query"},{"name":"type","description":"Relationship type","required":false,"paramType":"query"},{"name":"format","defaultValue":"json","description":"API response format","required":true,"allowableValues":"json,xml","paramType":"path"}],"response":[{"valueType":"List[related]","errorResponses":[{"reason":"Invalid word supplied.","code":400},{"reason":"No definitions found.","code":404}],"condition":"any"}],"summary":"Return related words (thesaurus data) for a word","open":false,"httpMethod":"GET"}]},{"path":"/word.{format}/{word}/phrases","description":"","operations":[{"parameters":[{"name":"word","description":"Word to fetch phrases for","required":true,"paramType":"path"},{"name":"limit","description":"Maximum number of results to return","required":false,"paramType":"query"},{"name":"wlmi","description":"Minimum WLMI for the phrase","required":false,"paramType":"query"},{"name":"useCanonical","description":"If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested.","required":false,"paramType":"query"},{"name":"format","defaultValue":"json","description":"API response format","required":true,"allowableValues":"json,xml","paramType":"path"}],"response":[{"valueType":"List[bigram]","errorResponses":[{"reason":"Invalid word supplied.","code":400}],"condition":"any"}],"summary":"Fetches bi-gram phrases for a word","open":false,"httpMethod":"GET"}]},{"path":"/word.{format}/{word}/hyphenation","description":"","operations":[{"parameters":[{"name":"word","description":"Word to get syllables for","required":true,"paramType":"path"},{"name":"useCanonical","description":"If true will try to return a correct word root ('cats' -> 'cat'). If false returns exactly what was requested.","required":false,"paramType":"query"},{"name":"sourceDictionary","description":"Get from a single dictionary. Valid options: ahd, century, wiktionary, webster, and wordnet.","required":false,"paramType":"query"},{"name":"limit","description":"Maximum number of results to return","required":false,"paramType":"query"},{"name":"format","defaultValue":"json","description":"API response format","required":true,"allowableValues":"json,xml","paramType":"path"}],"response":[{"valueType":"List[syllable]","errorResponses":[{"reason":"Invalid word supplied.","code":400}],"condition":"any"}],"summary":"Returns syllable information for a word","open":false,"httpMethod":"GET"}]},{"path":"/word.{format}/{word}/pronunciations","description":"","operations":[{"parameters":[{"name":"word","description":"Word to get pronunciations for","required":true,"paramType":"path"},{"name":"useCanonical","description":"If true will try to return a correct word root ('cats' -> 'cat'). If false returns exactly what was requested.","required":false,"paramType":"query"},{"name":"sourceDictionary","description":"Get from a single dictionary.","required":false,"allowableValues":"ahd,century,cmu,wiktionary,webster,wordnet","paramType":"query"},{"name":"typeFormat","description":"Text pronunciation type","required":false,"allowableValues":"ahd,arpabet,gcide-diacritical","paramType":"query"},{"name":"limit","description":"Maximum number of results to return","required":false,"paramType":"query"},{"name":"format","defaultValue":"json","description":"API response format","required":true,"allowableValues":"json,xml","paramType":"path"}],"response":[{"valueType":"List[textPron]","errorResponses":[{"reason":"Invalid word supplied.","code":400}],"condition":"any"}],"summary":"Returns text pronunciations for a given word","open":false,"httpMethod":"GET"}]},{"path":"/word.{format}/{word}/audio","description":"","operations":[{"parameters":[{"name":"word","description":"Word to get audio for.","required":true,"paramType":"path"},{"name":"useCanonical","description":"Use the canonical form of the word.","required":false,"paramType":"query"},{"name":"limit","description":"Maximum number of results to return","required":false,"paramType":"query"},{"name":"format","defaultValue":"json","description":"API response format","required":true,"allowableValues":"json,xml","paramType":"path"}],"response":[{"valueType":"List[audioObject]","errorResponses":[{"reason":"Invalid word supplied.","code":400}],"condition":"any"},{"valueType":"List[audioFile]","errorResponses":[{"reason":"Invalid word supplied.","code":400}],"condition":"any"}],"summary":"Fetches audio metadata for a word.","open":false,"notes":"The metadata includes a time-expiring fileUrl which allows reading the audio file directly from the API. Currently only audio pronunciations from the American Heritage Dictionary in mp3 format are supported.","httpMethod":"GET"}]}],"models":[{"name":"note","fields":[{"name":"noteType","description":"Contains the type of note","required":false,"allowableValues":"x, y, z","internalDescription":"Need to replace x, y z","paramAccess":"open","paramType":"string"},{"name":"pos","required":false,"paramType":"int"},{"name":"value","required":false,"paramType":"string"},{"name":"appliesTo","required":false,"paramType":"List[string]"}]},{"name":"example","fields":[{"name":"year","required":false,"paramType":"integer"},{"name":"provider","required":false,"paramType":"contentProvider"},{"name":"url","required":false,"paramType":"string"},{"name":"word","required":false,"paramType":"string"},{"name":"text","required":false,"paramType":"string"},{"name":"title","required":false,"paramType":"string"},{"name":"rating","required":false,"paramType":"float"},{"name":"exampleId","required":false,"paramType":"long"},{"name":"documentId","required":false,"paramType":"long"}]},{"name":"definition","fields":[{"name":"exampleUsage","required":false,"wrapperName":"exampleUses","paramType":"List[ExampleUsage]"},{"name":"word","required":false,"paramType":"string"},{"name":"text","required":false,"paramType":"string"},{"name":"textPron","required":false,"wrapperName":"textProns","paramType":"List[textPron]"},{"name":"partOfSpeech","required":false,"paramType":"string"},{"name":"note","required":false,"wrapperName":"notes","paramType":"List[note]"},{"name":"citation","required":false,"wrapperName":"citations","paramType":"List[citation]"},{"name":"relWord","required":false,"wrapperName":"relatedWords","paramType":"List[related]"},{"name":"sourceDictionary","required":false,"paramType":"string"},{"name":"label","required":false,"wrapperName":"labels","paramType":"List[Label]"},{"name":"sequence","required":false,"paramType":"string"},{"name":"seqString","required":false,"paramType":"string"},{"name":"extendedText","required":false,"paramType":"string"}]},{"name":"category","fields":[{"name":"name","required":false,"paramType":"string"}]},{"name":"frequency","fields":[{"name":"year","required":false,"paramType":"int"},{"name":"count","required":false,"paramType":"long"}]},{"name":"contentProvider","fields":[{"name":"name","required":false,"paramType":"string"},{"name":"id","required":false,"paramType":"int"}]},{"name":"audioType","fields":[{"name":"name","required":false,"paramType":"string"},{"name":"id","required":false,"paramType":"int"}]},{"name":"ExampleUsage","fields":[{"name":"text","required":false,"paramType":"string"}]},{"name":"root","fields":[{"name":"name","required":false,"paramType":"string"},{"name":"categories","required":false,"paramType":"List[category]"}]},{"name":"frequencySummary","fields":[{"name":"word","required":false,"paramType":"string"},{"name":"totalCount","required":false,"paramType":"long"},{"name":"frequency","required":false,"paramType":"List[frequency]"},{"name":"unknownYearCount","required":false,"paramType":"int"},{"name":"countForYear","required":false,"paramType":"long"}]},{"name":"citation","fields":[{"name":"source","required":false,"paramType":"string"},{"name":"cite","required":false,"paramType":"string"}]},{"name":"audioType","fields":[{"name":"name","required":false,"paramType":"string"},{"name":"id","required":false,"paramType":"int"}]},{"name":"scoredWord","fields":[{"name":"id","required":false,"paramType":"long"},{"name":"wordType","required":false,"paramType":"string"},{"name":"position","required":false,"paramType":"int"},{"name":"word","required":false,"paramType":"string"},{"name":"score","required":false,"paramType":"float"},{"name":"sentenceId","required":false,"paramType":"long"},{"name":"partOfSpeech","required":false,"paramType":"string"}]},{"name":"facetValue","fields":[{"name":"value","required":false,"paramType":"string"},{"name":"count","required":false,"paramType":"long"}]},{"name":"sentence","fields":[{"name":"id","required":false,"paramType":"long"},{"name":"scoredWord","required":false,"wrapperName":"scoredWords","paramType":"List[scoredWord]"},{"name":"display","required":false,"paramType":"string"},{"name":"documentMetadataId","required":false,"paramType":"long"},{"name":"rating","required":false,"paramType":"int"}]},{"name":"facet","fields":[{"name":"name","required":false,"paramType":"string"},{"name":"facetValue","required":false,"wrapperName":"facetValues","paramType":"List[facetValue]"}]},{"name":"wordObject","fields":[{"name":"word","required":false,"paramType":"string"},{"name":"vulgar","required":false,"paramType":"string"}]},{"name":"bigram","fields":[{"name":"count","required":false,"paramType":"long"},{"name":"gram1","required":false,"paramType":"string"},{"name":"gram2","required":false,"paramType":"string"},{"name":"mi","required":false,"paramType":"double"},{"name":"wlmi","required":false,"paramType":"double"}]},{"name":"related","fields":[{"name":"word","required":false,"wrapperName":"words","paramType":"List[string]"},{"name":"relationshipType","required":false,"paramType":"string"},{"name":"label1","required":false,"paramType":"string"},{"name":"label2","required":false,"paramType":"string"},{"name":"label3","required":false,"paramType":"string"},{"name":"label4","required":false,"paramType":"string"},{"name":"gram","required":false,"paramType":"string"}]},{"name":"exampleSearchResults","fields":[{"name":"facet","required":false,"wrapperName":"facets","paramType":"List[facet]"},{"name":"example","required":false,"wrapperName":"examples","paramType":"List[example]"},{"name":"totalResults","required":false,"paramType":"int"}]},{"name":"frequencySummaryE","fields":[{"name":"elements","required":false,"paramType":"List[frequencyElement]"}]},{"name":"partOfSpeech","fields":[{"name":"roots","required":false,"paramType":"List[root]"}]},{"name":"syllable","fields":[{"name":"type","required":false,"paramType":"string"},{"name":"seq","required":false,"paramType":"int"},{"name":"text","required":false,"paramType":"string"}]},{"name":"textPron","fields":[{"name":"id","required":false,"paramType":"long"},{"name":"seq","required":false,"paramType":"int"},{"name":"raw","required":false,"paramType":"string"},{"name":"rawType","required":false,"paramType":"string"}]},{"name":"Label","fields":[{"name":"type","required":false,"paramType":"string"},{"name":"text","required":false,"paramType":"string"}]},{"name":"audioFile","fields":[{"name":"id","required":true,"paramType":"long"},{"name":"description","required":false,"paramType":"string"},{"name":"createdBy","required":false,"paramType":"string"},{"name":"word","required":false,"paramType":"string"},{"name":"createdAt","required":false,"paramType":"Date"},{"name":"commentCount","required":false,"paramType":"int"},{"name":"voteCount","required":false,"paramType":"integer"},{"name":"voteAverage","required":false,"paramType":"float"},{"name":"voteWeightedAverage","required":false,"paramType":"float"},{"name":"fileUrl","required":false,"paramType":"string"}]},{"name":"frequencyElement","fields":[{"name":"year","required":false,"paramType":"int"},{"name":"lowerWisker","required":false,"paramType":"double"},{"name":"upperWisker","required":false,"paramType":"double"},{"name":"lowerBox","required":false,"paramType":"double"},{"name":"upperBox","required":false,"paramType":"double"}]},{"name":"audioObject","fields":[{"name":"id","required":false,"paramType":"long"},{"name":"type","required":false,"paramType":"audioType"},{"name":"description","required":false,"paramType":"string"},{"name":"userId","required":false,"paramType":"long"},{"name":"createdBy","required":false,"paramType":"string"},{"name":"wordstring","required":false,"paramType":"string"},{"name":"wordId","required":false,"paramType":"long"},{"name":"createdAt","required":false,"paramType":"Date"},{"name":"filePath","required":false,"paramType":"string"},{"name":"recordId","required":false,"paramType":"string"},{"name":"audioFileType","required":false,"paramType":"audioType"},{"name":"audioFileId","required":false,"paramType":"long"},{"name":"streamPath","required":false,"paramType":"string"}]}]}
|
|
1
|
+
{"endPoints":[{"path":"/word.{format}/{word}","description":"","operations":[{"parameters":[{"name":"word","description":"String value of WordObject to return","required":true,"paramType":"path"},{"name":"useCanonical","description":"If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested.","required":false,"paramType":"query"},{"name":"includeSuggestions","description":"Return suggestions (for correct spelling, case variants, etc.)","required":false,"paramType":"query"},{"name":"format","defaultValue":"json","description":"API response format","required":true,"allowableValues":"json,xml","paramType":"path"}],"response":[{"valueType":"wordObject","errorResponses":[{"reason":"Invalid word supplied.","code":400}],"condition":"any"}],"summary":"Given a word as a string, returns the WordObject that represents it","open":false,"httpMethod":"GET"}]},{"path":"/word.{format}/{word}/examples","description":"","operations":[{"parameters":[{"name":"word","description":"Word to return examples for","required":true,"paramType":"path"},{"name":"limit","description":"Maximum number of results to return","required":false,"paramType":"query"},{"name":"includeDuplicates","description":"Show duplicate examples from different sources","required":false,"paramType":"query"},{"name":"contentProvider","description":"Return results from a specific ContentProvider","required":false,"paramType":"query"},{"name":"useCanonical","description":"If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested.","required":false,"paramType":"query"},{"name":"skip","description":"Results to skip","required":false,"paramType":"query"},{"name":"limit","description":"Maximum number of results to return","required":false,"paramType":"query"},{"name":"format","defaultValue":"json","description":"API response format","required":true,"allowableValues":"json,xml","paramType":"path"}],"response":[{"valueType":"exampleSearchResults","errorResponses":[{"reason":"Invalid word supplied.","code":400}],"condition":"any"}],"summary":"Returns examples for a word","open":false,"httpMethod":"GET"}]},{"path":"/word.{format}/{word}/definitions","description":"","operations":[{"parameters":[{"name":"word","description":"Word to return definitions for","required":true,"paramType":"path"},{"name":"limit","description":"Maximum number of results to return","required":false,"paramType":"query"},{"name":"partOfSpeech","description":"CSV list of part-of-speech types","required":false,"allowableValues":"noun,adjective,verb,adverb,interjection,pronoun,preposition,abbreviation,affix,article,auxiliary-verb,conjunction,definite-article,family-name,given-name,idiom,imperative,noun-plural,noun-posessive,past-participle,phrasal-prefix,proper-noun,proper-noun-plural,proper-noun-posessive,suffix,verb-intransitive,verb-transitive","paramType":"query"},{"name":"includeRelated","description":"Return related words with definitions","required":false,"allowableValues":"true,false","paramType":"query"},{"name":"sourceDictionaries","description":"Gets from dictionaries in the supplied order of precedence","required":false,"allowableValues":"ahd, century, wiktionary, webster, wordnet","paramType":"query"},{"name":"useCanonical","description":"If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested.","required":false,"allowableValues":"false,true","paramType":"query"},{"name":"includeTags","description":"Return a closed set of XML tags in response","required":false,"allowableValues":"false,true","paramType":"query"},{"name":"format","defaultValue":"json","description":"API response format","required":true,"allowableValues":"json,xml","paramType":"path"}],"response":[{"valueType":"List[definition]","errorResponses":[{"reason":"Invalid word supplied.","code":400},{"reason":"No definitions found.","code":404}],"condition":"any"}],"summary":"Return definitions for a word","open":false,"httpMethod":"GET"}]},{"path":"/word.{format}/{word}/frequency","description":"","operations":[{"parameters":[{"name":"word","description":"Word to return","required":true,"paramType":"path"},{"name":"useCanonical","description":"If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested.","required":false,"paramType":"query"},{"name":"startYear","description":"Starting Year","required":false,"paramType":"query"},{"name":"endYear","description":"Ending Year","required":false,"paramType":"query"},{"name":"format","defaultValue":"json","description":"API response format","required":true,"allowableValues":"json,xml","paramType":"path"}],"response":[{"valueType":"frequencySummary","errorResponses":[{"reason":"Invalid word supplied.","code":400},{"reason":"No results.","code":404}],"condition":"any"},{"valueType":"frequencySummaryE","errorResponses":[{"reason":"Invalid word supplied.","code":400},{"reason":"No results.","code":404}],"condition":"errorBars=true"}],"summary":"Returns word usage over time","open":false,"httpMethod":"GET"}]},{"path":"/word.{format}/{word}/topExample","description":"","operations":[{"parameters":[{"name":"word","description":"Word to fetch examples for","required":true,"paramType":"path"},{"name":"contentProvider","description":"Return results from a specific ContentProvider","required":false,"paramType":"query"},{"name":"useCanonical","description":"If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested.","required":false,"paramType":"query"},{"name":"format","defaultValue":"json","description":"API response format","required":true,"allowableValues":"json,xml","paramType":"path"}],"response":[{"valueType":"example","errorResponses":[{"reason":"Invalid word supplied.","code":400}],"condition":"any"}],"summary":"Returns a top example for a word","open":false,"httpMethod":"GET"}]},{"path":"/word.{format}/{word}/related","description":"","operations":[{"parameters":[{"name":"word","description":"Word for which to return related words","required":true,"paramType":"path"},{"name":"partOfSpeech","description":"CSV list of part-of-speech types","required":false,"allowableValues":"noun,adjective,verb,adverb,interjection,pronoun,preposition,abbreviation,affix,article,auxiliary-verb,conjunction,definite-article,family-name,given-name,idiom,imperative,noun-plural,noun-posessive,past-participle,phrasal-prefix,proper-noun,proper-noun-plural,proper-noun-posessive,suffix,verb-intransitive,verb-transitive","paramType":"query"},{"name":"sourceDictionary","description":"Get data from a single dictionary. Valid options are ahd, century, wiktionary, webster, and wordnet.","required":false,"paramType":"query"},{"name":"limit","description":"Maximum number of results to return","required":false,"paramType":"query"},{"name":"useCanonical","description":"If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested.","required":false,"allowableValues":"false,true","paramType":"query"},{"name":"type","description":"Relationship type","required":false,"allowableValues":"synonym,antonym,variant,equivalent,cross-reference,related-word,rhyme,form,etymologically-related-term,hypernym,hyponym,inflected-form,primary,same-context,verb-form,verb-stem,unknown","paramType":"query"},{"name":"format","defaultValue":"json","description":"API response format","required":true,"allowableValues":"json,xml","paramType":"path"}],"response":[{"valueType":"List[related]","errorResponses":[{"reason":"Invalid word supplied.","code":400},{"reason":"No definitions found.","code":404}],"condition":"any"}],"summary":"Return related words (thesaurus data) for a word","open":false,"httpMethod":"GET"}]},{"path":"/word.{format}/{word}/phrases","description":"","operations":[{"parameters":[{"name":"word","description":"Word to fetch phrases for","required":true,"paramType":"path"},{"name":"limit","description":"Maximum number of results to return","required":false,"paramType":"query"},{"name":"wlmi","description":"Minimum WLMI for the phrase","required":false,"paramType":"query"},{"name":"useCanonical","description":"If true will try to return the correct word root ('cats' -> 'cat'). If false returns exactly what was requested.","required":false,"paramType":"query"},{"name":"format","defaultValue":"json","description":"API response format","required":true,"allowableValues":"json,xml","paramType":"path"}],"response":[{"valueType":"List[bigram]","errorResponses":[{"reason":"Invalid word supplied.","code":400}],"condition":"any"}],"summary":"Fetches bi-gram phrases for a word","open":false,"httpMethod":"GET"}]},{"path":"/word.{format}/{word}/hyphenation","description":"","operations":[{"parameters":[{"name":"word","description":"Word to get syllables for","required":true,"paramType":"path"},{"name":"useCanonical","description":"If true will try to return a correct word root ('cats' -> 'cat'). If false returns exactly what was requested.","required":false,"paramType":"query"},{"name":"sourceDictionary","description":"Get from a single dictionary. Valid options: ahd, century, wiktionary, webster, and wordnet.","required":false,"paramType":"query"},{"name":"limit","description":"Maximum number of results to return","required":false,"paramType":"query"},{"name":"format","defaultValue":"json","description":"API response format","required":true,"allowableValues":"json,xml","paramType":"path"}],"response":[{"valueType":"List[syllable]","errorResponses":[{"reason":"Invalid word supplied.","code":400}],"condition":"any"}],"summary":"Returns syllable information for a word","open":false,"httpMethod":"GET"}]},{"path":"/word.{format}/{word}/pronunciations","description":"","operations":[{"parameters":[{"name":"word","description":"Word to get pronunciations for","required":true,"paramType":"path"},{"name":"useCanonical","description":"If true will try to return a correct word root ('cats' -> 'cat'). If false returns exactly what was requested.","required":false,"paramType":"query"},{"name":"sourceDictionary","description":"Get from a single dictionary.","required":false,"allowableValues":"ahd,century,cmu,wiktionary,webster,wordnet","paramType":"query"},{"name":"typeFormat","description":"Text pronunciation type","required":false,"allowableValues":"ahd,arpabet,gcide-diacritical","paramType":"query"},{"name":"limit","description":"Maximum number of results to return","required":false,"paramType":"query"},{"name":"format","defaultValue":"json","description":"API response format","required":true,"allowableValues":"json,xml","paramType":"path"}],"response":[{"valueType":"List[textPron]","errorResponses":[{"reason":"Invalid word supplied.","code":400}],"condition":"any"}],"summary":"Returns text pronunciations for a given word","open":false,"httpMethod":"GET"}]},{"path":"/word.{format}/{word}/audio","description":"","operations":[{"parameters":[{"name":"word","description":"Word to get audio for.","required":true,"paramType":"path"},{"name":"useCanonical","description":"Use the canonical form of the word.","required":false,"paramType":"query"},{"name":"limit","description":"Maximum number of results to return","required":false,"paramType":"query"},{"name":"format","defaultValue":"json","description":"API response format","required":true,"allowableValues":"json,xml","paramType":"path"}],"response":[{"valueType":"List[audioObject]","errorResponses":[{"reason":"Invalid word supplied.","code":400}],"condition":"any"},{"valueType":"List[audioFile]","errorResponses":[{"reason":"Invalid word supplied.","code":400}],"condition":"any"}],"summary":"Fetches audio metadata for a word.","open":false,"notes":"The metadata includes a time-expiring fileUrl which allows reading the audio file directly from the API. Currently only audio pronunciations from the American Heritage Dictionary in mp3 format are supported.","httpMethod":"GET"}]}],"models":[{"name":"note","fields":[{"name":"noteType","description":"Contains the type of note","required":false,"allowableValues":"x, y, z","internalDescription":"Need to replace x, y z","paramAccess":"open","paramType":"string"},{"name":"pos","required":false,"paramType":"int"},{"name":"value","required":false,"paramType":"string"},{"name":"appliesTo","required":false,"paramType":"List[string]"}]},{"name":"example","fields":[{"name":"year","required":false,"paramType":"integer"},{"name":"provider","required":false,"paramType":"contentProvider"},{"name":"url","required":false,"paramType":"string"},{"name":"word","required":false,"paramType":"string"},{"name":"text","required":false,"paramType":"string"},{"name":"title","required":false,"paramType":"string"},{"name":"rating","required":false,"paramType":"float"},{"name":"exampleId","required":false,"paramType":"long"},{"name":"documentId","required":false,"paramType":"long"}]},{"name":"definition","fields":[{"name":"exampleUsage","required":false,"wrapperName":"exampleUses","paramType":"List[ExampleUsage]"},{"name":"word","required":false,"paramType":"string"},{"name":"text","required":false,"paramType":"string"},{"name":"textPron","required":false,"wrapperName":"textProns","paramType":"List[textPron]"},{"name":"partOfSpeech","required":false,"paramType":"string"},{"name":"note","required":false,"wrapperName":"notes","paramType":"List[note]"},{"name":"citation","required":false,"wrapperName":"citations","paramType":"List[citation]"},{"name":"relWord","required":false,"wrapperName":"relatedWords","paramType":"List[related]"},{"name":"sourceDictionary","required":false,"paramType":"string"},{"name":"label","required":false,"wrapperName":"labels","paramType":"List[Label]"},{"name":"sequence","required":false,"paramType":"string"},{"name":"seqString","required":false,"paramType":"string"},{"name":"extendedText","required":false,"paramType":"string"}]},{"name":"frequency","fields":[{"name":"year","required":false,"paramType":"int"},{"name":"count","required":false,"paramType":"long"}]},{"name":"contentProvider","fields":[{"name":"name","required":false,"paramType":"string"},{"name":"id","required":false,"paramType":"int"}]},{"name":"audioType","fields":[{"name":"name","required":false,"paramType":"string"},{"name":"id","required":false,"paramType":"int"}]},{"name":"ExampleUsage","fields":[{"name":"text","required":false,"paramType":"string"}]},{"name":"frequencySummary","fields":[{"name":"word","required":false,"paramType":"string"},{"name":"totalCount","required":false,"paramType":"long"},{"name":"frequency","required":false,"paramType":"List[frequency]"},{"name":"unknownYearCount","required":false,"paramType":"int"},{"name":"countForYear","required":false,"paramType":"long"}]},{"name":"citation","fields":[{"name":"source","required":false,"paramType":"string"},{"name":"cite","required":false,"paramType":"string"}]},{"name":"audioType","fields":[{"name":"name","required":false,"paramType":"string"},{"name":"id","required":false,"paramType":"int"}]},{"name":"scoredWord","fields":[{"name":"id","required":false,"paramType":"long"},{"name":"wordType","required":false,"paramType":"string"},{"name":"position","required":false,"paramType":"int"},{"name":"word","required":false,"paramType":"string"},{"name":"score","required":false,"paramType":"float"},{"name":"sentenceId","required":false,"paramType":"long"},{"name":"partOfSpeech","required":false,"paramType":"string"}]},{"name":"facetValue","fields":[{"name":"value","required":false,"paramType":"string"},{"name":"count","required":false,"paramType":"long"}]},{"name":"sentence","fields":[{"name":"id","required":false,"paramType":"long"},{"name":"scoredWord","required":false,"wrapperName":"scoredWords","paramType":"List[scoredWord]"},{"name":"display","required":false,"paramType":"string"},{"name":"documentMetadataId","required":false,"paramType":"long"},{"name":"rating","required":false,"paramType":"int"}]},{"name":"facet","fields":[{"name":"name","required":false,"paramType":"string"},{"name":"facetValue","required":false,"wrapperName":"facetValues","paramType":"List[facetValue]"}]},{"name":"wordObject","fields":[{"name":"word","required":false,"paramType":"string"},{"name":"vulgar","required":false,"paramType":"string"}]},{"name":"bigram","fields":[{"name":"count","required":false,"paramType":"long"},{"name":"gram1","required":false,"paramType":"string"},{"name":"gram2","required":false,"paramType":"string"},{"name":"mi","required":false,"paramType":"double"},{"name":"wlmi","required":false,"paramType":"double"}]},{"name":"related","fields":[{"name":"word","required":false,"wrapperName":"words","paramType":"List[string]"},{"name":"relationshipType","required":false,"paramType":"string"},{"name":"label1","required":false,"paramType":"string"},{"name":"label2","required":false,"paramType":"string"},{"name":"label3","required":false,"paramType":"string"},{"name":"label4","required":false,"paramType":"string"},{"name":"gram","required":false,"paramType":"string"}]},{"name":"exampleSearchResults","fields":[{"name":"facet","required":false,"wrapperName":"facets","paramType":"List[facet]"},{"name":"example","required":false,"wrapperName":"examples","paramType":"List[example]"},{"name":"totalResults","required":false,"paramType":"int"}]},{"name":"frequencySummaryE","fields":[{"name":"elements","required":false,"paramType":"List[frequencyElement]"}]},{"name":"partOfSpeech","fields":[{"name":"roots","required":false,"paramType":"List[root]"}]},{"name":"syllable","fields":[{"name":"type","required":false,"paramType":"string"},{"name":"seq","required":false,"paramType":"int"},{"name":"text","required":false,"paramType":"string"}]},{"name":"textPron","fields":[{"name":"id","required":false,"paramType":"long"},{"name":"seq","required":false,"paramType":"int"},{"name":"raw","required":false,"paramType":"string"},{"name":"rawType","required":false,"paramType":"string"}]},{"name":"Label","fields":[{"name":"type","required":false,"paramType":"string"},{"name":"text","required":false,"paramType":"string"}]},{"name":"audioFile","fields":[{"name":"id","required":true,"paramType":"long"},{"name":"description","required":false,"paramType":"string"},{"name":"createdBy","required":false,"paramType":"string"},{"name":"word","required":false,"paramType":"string"},{"name":"createdAt","required":false,"paramType":"Date"},{"name":"commentCount","required":false,"paramType":"int"},{"name":"voteCount","required":false,"paramType":"integer"},{"name":"voteAverage","required":false,"paramType":"float"},{"name":"voteWeightedAverage","required":false,"paramType":"float"},{"name":"fileUrl","required":false,"paramType":"string"}]},{"name":"frequencyElement","fields":[{"name":"year","required":false,"paramType":"int"},{"name":"lowerWisker","required":false,"paramType":"double"},{"name":"upperWisker","required":false,"paramType":"double"},{"name":"lowerBox","required":false,"paramType":"double"},{"name":"upperBox","required":false,"paramType":"double"}]},{"name":"audioObject","fields":[{"name":"id","required":false,"paramType":"long"},{"name":"type","required":false,"paramType":"audioType"},{"name":"description","required":false,"paramType":"string"},{"name":"userId","required":false,"paramType":"long"},{"name":"createdBy","required":false,"paramType":"string"},{"name":"wordstring","required":false,"paramType":"string"},{"name":"wordId","required":false,"paramType":"long"},{"name":"createdAt","required":false,"paramType":"Date"},{"name":"filePath","required":false,"paramType":"string"},{"name":"recordId","required":false,"paramType":"string"},{"name":"audioFileType","required":false,"paramType":"audioType"},{"name":"audioFileId","required":false,"paramType":"long"},{"name":"streamPath","required":false,"paramType":"string"}]}]}
|
data/lib/wordnik/operation.rb
CHANGED
|
@@ -6,7 +6,7 @@ module Wordnik
|
|
|
6
6
|
include ActiveModel::Conversion
|
|
7
7
|
extend ActiveModel::Naming
|
|
8
8
|
|
|
9
|
-
attr_accessor :endpoint, :http_method, :summary, :notes, :parameters, :response, :open, :nickname
|
|
9
|
+
attr_accessor :endpoint, :http_method, :summary, :notes, :parameters, :response, :open, :nickname, :deprecated
|
|
10
10
|
|
|
11
11
|
validates_presence_of :endpoint, :http_method, :summary, :notes, :parameters, :response, :open
|
|
12
12
|
|
|
@@ -28,23 +28,14 @@ module Wordnik
|
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
# Define nickname
|
|
31
|
-
self.nickname =
|
|
32
|
-
join("_"). # join http method and path
|
|
33
|
-
gsub(/\{\w+\}/, ""). # remove path params
|
|
34
|
-
tr("/", "_"). # replace slashes with underscores
|
|
35
|
-
tr(' .', ''). # remove spaces and dots
|
|
36
|
-
underscore. # underscore
|
|
37
|
-
gsub(/_+/, "_"). # reduce multiple consective underscores to one
|
|
38
|
-
gsub("_#{self.endpoint.resource.name.to_s.underscore}", ""). # remove resource name
|
|
39
|
-
gsub(/_$/, "") # remove underscore from end of string
|
|
40
|
-
|
|
31
|
+
self.nickname = Operation.nicknameify(self.http_method, self.endpoint.path, self.endpoint.resource.name)
|
|
41
32
|
end
|
|
42
33
|
|
|
43
34
|
# A globally unique identifier for the operation
|
|
44
35
|
def slug
|
|
45
36
|
[self.endpoint.resource.name, self.nickname].join("_")
|
|
46
37
|
end
|
|
47
|
-
|
|
38
|
+
|
|
48
39
|
def get?
|
|
49
40
|
self.http_method.downcase == "get"
|
|
50
41
|
end
|
|
@@ -80,6 +71,21 @@ module Wordnik
|
|
|
80
71
|
parameter
|
|
81
72
|
end.compact
|
|
82
73
|
end
|
|
74
|
+
|
|
75
|
+
# Generate a nickname using an HTTP method. This is used at operations initialization
|
|
76
|
+
# and for doing backward searches to generate sample convenience calls from raw requests.
|
|
77
|
+
def self.nicknameify(http_method, path, resource_name)
|
|
78
|
+
[http_method, path].
|
|
79
|
+
join("_"). # join http method and path
|
|
80
|
+
gsub(/\{\w+\}/, ""). # remove path params
|
|
81
|
+
tr("/", "_"). # replace slashes with underscores
|
|
82
|
+
tr(' .', ''). # remove spaces and dots
|
|
83
|
+
underscore. # underscore
|
|
84
|
+
gsub(/_+/, "_"). # reduce multiple consective underscores to one
|
|
85
|
+
gsub("_#{resource_name.to_s.underscore}", ""). # remove resource name
|
|
86
|
+
gsub(/_$/, "") # remove underscore from end of string
|
|
87
|
+
end
|
|
88
|
+
|
|
83
89
|
|
|
84
90
|
end
|
|
85
91
|
|
|
@@ -6,7 +6,7 @@ module Wordnik
|
|
|
6
6
|
include ActiveModel::Conversion
|
|
7
7
|
extend ActiveModel::Naming
|
|
8
8
|
|
|
9
|
-
attr_accessor :name, :description, :required, :param_type, :default_value, :allowable_values, :param_access, :internal_description, :wrapper_name
|
|
9
|
+
attr_accessor :name, :description, :required, :param_type, :default_value, :allowable_values, :param_access, :internal_description, :wrapper_name, :data_type
|
|
10
10
|
|
|
11
11
|
def initialize(attributes = {})
|
|
12
12
|
attributes.each do |name, value|
|
data/lib/wordnik/resource.rb
CHANGED
|
@@ -32,28 +32,9 @@ module Wordnik
|
|
|
32
32
|
return endpoint.path if operation.nickname == nickname
|
|
33
33
|
end
|
|
34
34
|
end
|
|
35
|
+
nil
|
|
35
36
|
end
|
|
36
|
-
|
|
37
|
-
# def operation_nickname_pairs
|
|
38
|
-
# return @pairs if @pairs
|
|
39
|
-
# return unless self.endpoints.present?
|
|
40
|
-
# @pairs = {}
|
|
41
|
-
# self.endpoints.map do |endpoint|
|
|
42
|
-
# endpoint.operations.map do |operation|
|
|
43
|
-
# nickname_parts = []
|
|
44
|
-
# nickname_parts << operation.http_method
|
|
45
|
-
# nickname_parts << endpoint.path.gsub(/\{\w+\}/, "").tr("/", "_").tr(' .', '').underscore
|
|
46
|
-
# nickname = nickname_parts.
|
|
47
|
-
# join("_").
|
|
48
|
-
# gsub(/_+/, "_").
|
|
49
|
-
# gsub("_#{self.name.to_s.underscore}", "").
|
|
50
|
-
# gsub(/_$/, "")
|
|
51
|
-
# @pairs[nickname] = endpoint.path
|
|
52
|
-
# end
|
|
53
|
-
# end
|
|
54
|
-
# @pairs
|
|
55
|
-
# end
|
|
56
|
-
|
|
37
|
+
|
|
57
38
|
# Uses the received method name and arguments to dynamically construct a Request
|
|
58
39
|
# If the method name is prefixed with 'build_', then the 'unmade' Request
|
|
59
40
|
# object will be returned instead of the Request Response's body
|
data/lib/wordnik/version.rb
CHANGED
data/spec/request_spec.rb
CHANGED